Giter Club home page Giter Club logo

media's Introduction

Media for TYPO3 CMS badge_travis badge_scrutinizer badge_coverage

Media is a tool for managing Assets for TYPO3 CMS 6.2 and is logically built on the top of FAL. The File Abstraction Layer API was introduced in TYPO3 6.0 and allows to handle files in centralised way across the CMS. Basically, Media provides the following set of features:

  • Advanced metadata handling of Assets
  • A user friendly BE module
  • Mass upload of files and post processing of files
  • Multi language handling of metadata
  • Integration with the text editor (RTE)

https://raw.github.com/fabarea/media/master/Documentation/MediaModule-01.png

General View of the BE module. Latest version of Media makes use of the folder tree. This can be activated / deactivated in the Extension Manager. Notice that files can be browsed recursively by clicking the checkbox on the top right:

https://raw.github.com/fabarea/media/master/Documentation/Intro-02.png

Fields can be displayed / hidden by picking the available columns in the drop down menu.

https://raw.github.com/fabarea/media/master/Documentation/Intro-01.png

Advanced searching of files, by title, by categories, by usage, etc... Criteria can be cumulated.

https://raw.github.com/fabarea/media/master/Documentation/Intro-03.png

Inline editing is as simple as clicking in the cell.

https://raw.github.com/fabarea/media/master/Documentation/Intro-04.png

Translation of files can be done inline.

https://raw.github.com/fabarea/media/master/Documentation/Intro-05.png

Mass edit the metadata of the files. Editable columns have an editing icon on the top where to edit a bunch of files.

https://raw.github.com/fabarea/media/master/Documentation/Intro-06.png

Export selected data to various format: CSV, XML, XLS

https://raw.github.com/fabarea/media/master/Documentation/Intro-07.png

A bunch of tools for the admin related to files: find duplicate files, thumbnail pre-generation, etc...

https://raw.github.com/fabarea/media/master/Documentation/Intro-08.png

Compatibility and Maintenance

This package is currently maintained for the following versions:

TYPO3 Version | Package Version | Branch | Maintained |

|-----------------------|-----------------|---------|---------------| | TYPO3 11.5.x | 6.x | master | Yes | | TYPO3 11.5.x | 5.x | - | Yes | | TYPO3 10.4.x | 4.x | - | No | | TYPO3 6.2.x | 3.x | - | No | | TYPO3 6.1.x | 2.x | - | No | | TYPO3 6.1.x | 1.x | - | No |

Project info and releases

Home page of the project: https://github.com/fabarea/media

Stable version released on TER: http://typo3.org/extensions/repository/view/media

Development version from Git:

cd typ3conf/ext
git clone https://github.com/fabarea/media.git

Flash news are also announced on http://twitter.com/fudriot

Installation

Download the source code either from the Git repository or from the TER for the stable versions. Install the extension as normal in the Extension Manager.

Configuration

Some settings, such as default categories applied upon upload, are global and must be configured in the settings of Media in the Extension Manager.

https://raw.github.com/fabarea/media/master/Documentation/ExtensionManager-01.png

Enable for the Editor User the correct permissions in the Backend User Group so that it can access the Media module and be able to upload files.

https://raw.github.com/fabarea/media/master/Documentation/BackendUserGroup-01.png

Besides, since Media is multi-storage capable, many settings are to be configured per storage. Make sure they are correctly set. This will not be a problem for new storage created after Media is installed, they will have default values. However, for existing storage, they will be no value.

Edit the settings of a Storage:

https://raw.github.com/fabarea/media/master/Documentation/Manual-02.png

Apply different upload settings:

https://raw.github.com/fabarea/media/master/Documentation/Manual-03.png

Configured target folder for each file type:

https://raw.github.com/fabarea/media/master/Documentation/Manual-04.png

User TSConfig

You can use the option options.vidi.enableMediaFilePicker to control the display of the File Picker of Media. Pay attention, this option is only taken into consideration if the File Picker is activated in the Extension Manager first. The File Picker is the popup displayed to connect a File with a content element (like image) or with other kind of records. The Core popup is however used by default for the purpose of the folder tree. In the Media popup, the folder tree will not be displayed because of iframe issue. As tip, use the recursive browsing in Media to retrieve all your files:

# Define whether to use default file picker or the one from Media (default = 1) but
options.vidi.enableMediaFilePicker = 1

Suhosin

Please note that PHP setups with the Suhosin patch activated will have a default limit of 100 maximum number of variables that are allowed to be passed in the URL. This limit must be increased to 140:

suhosin.get.max_vars = 140

How to customize the Grid in Media module

Important to notice the Media BE module is powered by Vidi which is a List Component for TYPO3 CMS. To know more about Vidi and how to configure the Grid, refer to the Grid chapter.

View Helpers

Display list of files of category X

You can make use of a View Helper to retrieve a bunch of files on the Frontend. Let say we want to display a list of files "png" images coming from the storage "1" along with the associated categories. The code could look like this in your Fluid template:

<strong>Number of files: {v:content.count(matches: {storage: 1}, type: 'sys_file')}</strong>

<f:if condition="{v:content.find(matches: {storage: 1}, type: 'sys_file')}">
        <ul>
                <f:for each="{v:content.find(matches: '{storage: 1}', type: 'sys_file')}" as="file">
                        <li>
                                {file.uid} -
                                {file.metadata.title} -
                                <m:file.thumbnail file="{file}" output="imageWrapped"/>

                                <f:if condition="{file.metadata.categories}}">
                                        <ul>
                                                <f:for each="{file.metadata.categories}" as="category">
                                                        <li>{category.title}</li>
                                                </f:for>
                                        </ul>
                                </f:if>
                        </li>
                </f:for>
        </ul>
</f:if>

{namespace m=Fab\Media\ViewHelpers}
{namespace v=Fab\Vidi\ViewHelpers}

A more complex example here, we want to retrieve the same as before but all files belonging to categories 1,2 sorted by title as addition. We must provide "aliases" as workaround since Fluid would not parse the expression matches: {metadata.categories: '1,2'} and will return an exception.

<f:for each="{v:content.find(
                                        matches: {storage: 1, extension: 'png', categories: '1,2'},
                                        orderings: {title: 'ASC'},
                                        type: 'sys_file',
                                        aliases: {categories: 'metadata.categories', title: 'metadata.title'}
                                )}"
       as="file">

        <li>..</li>
</f:for>

Alternatively:

<f:for each="{v:content.find(selection: 'my-selection')}" as="file">

        <li>..</li>
</f:for>

The same can be achieved in a programming way:

// Get the Content Repository for sys_file.
$contentRepository = \Fab\Vidi\Domain\Repository\ContentRepositoryFactory::getInstance('sys_file');

// Initialize a Matcher object.
/** @var \Fab\Vidi\Persistence\Matcher $matcher */
$matcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Fab\Vidi\Persistence\Matcher::class);

// Add some criteria.
$matcher->equals('storage', '1');
$matcher->equals('metadata.categories', '1'); // "metadata" correspond to the join defined in the TCA of "sys_file".

// etc... you can add more criteria as instance a "like"
$matcher->like('metadata.title', 'foo');

// Fetch the objects.
$files = $contentRepository->findBy($matcher);

Thumbnail View Helper

The thumbnail API is meant to render a preview of a file independently of its type (image, document, video, ...). Notice, only thumbnail service for "image" and "document" is well implemented. Video and audio are still on the todo list. In case no appropriate thumbnail service is found, a fallback service is called generating a dummy thumbnail.

The Thumbnail View Helper can be used as follow:

    # The minimum required:
    <m:file.thumbnail file="{file}"/>

    # Give more settings to the thumbnail:
    <m:file.thumbnail file="{file}"
            configuration="{width: 800, height: 800}"
            attributes="{class: 'file-thumbnail'}"
            output="image"/>

    # Required attributes:
    # --------------------
    #
    # file="{file}"

    # Default values:
    # ---------------
    #
    # configuration= array()
    # attributes = array()
    # output = image (possible values: "uri", "image", "imageWrapped")
    # preset = NULL

    # Pass some preset as for the dimension. Values can be:
    # - image_thumbnail => '100x100'  (where maximum width is 100 and maximum height is 100)
    # - image_mini => '120x120'
    # - image_small => '320x320'
    # - image_medium => '760x760'
    # - image_large => '1200x1200'
    <m:file.thumbnail file="{file}" preset="image_medium"/>

    {namespace m=Fab\Media\ViewHelpers}

    # Or if your template contains ``<section />``,
    <html xmlns:f="http://typo3.org/ns/typo3/fluid/viewhelpers"
            xmlns:m="http://typo3.org/ns/Fab/Media/ViewHelpers">

            <section>
                    <m:file.thumbnail file="{file}" preset="image_medium"/>
            </section>
</html>

Besides the View Helper, a thumbnail can be generated in a programming way. The example illustrates some possibilities. For more insight, refer to the class itself. Here we go:

/** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */
$thumbnailService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailService', $fil::class);
$thumbnail = $thumbnailService
        ->setConfiguration($configuration)
        ->setOutputType(\Fab\Media\Thumbnail\ThumbnailInterface::OUTPUT_IMAGE_WRAPPED)
        ->setAppendTimeStamp(TRUE)
        ->create();

print $thumbnail
<a href="..." target="_blank">
        <img src="..." alt="..." title="..." />
</a>

Media Tools

Tools are registered through the Tool API provided by Vidi in ext_tables.php and can be accessed by clicking the upper right icon in the BE module. Those tools are visible for Admin only:

\Fab\Vidi\Tool\ToolRegistry::getInstance()->register('sys_file', 'Fab\Media\Tool\MissingFilesFinderTool');

File Upload API

In the BE module, File upload is handled by Fine Uploader which is a Javascript plugin aiming to bring a user-friendly file uploading experience over the web. The plugin relies on HTML5 technology which enables Drag & Drop from the Desktop as instance.

On the server side, there is an API which transparently handles whether the file come from an XHR request or a POST request.

# Code below is simplified for the documentation sake.
# Check out for more insight EXT:media/Classes/Controller/AssetController.php @ uploadAction

/** @var $uploadManager \Fab\Media\FileUpload\UploadManager */
$uploadManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Fab\Media\FileUpload\UploadManager::class);
try {
        /** @var $uploadedFileObject \Fab\Media\FileUpload\UploadedFileInterface */
        $uploadedFileObject = $uploadManager->handleUpload();
} catch (\Exception $e) {
        $response = array('error' => $e->getMessage());
}

$newFileObject = $targetFolder->addFile($uploadedFileObject->getFileWithAbsolutePath(), $uploadedFileObject->getName());

Image Optimizer API

When a image is uploaded, there is a post-processing step where the image can be optimized. By default there are two pre-configured optimizations: resize and rotate. The resize processing will reduce the size of an image in case it exceeds a certain dimension. The maximum dimension allowed is to be configured per storage. The rotate optimizer read the exif metadata and automatically rotates the image. For the auto-rotation features, credits go to Xavier Perseguers where great inspiration was found in one of his extension.

If needed, it is possible to add additional custom optimizers. Notice that the class must implement an interface \Fab\Media\FileUpload\ImageOptimizerInterface and can be added with following code:

\Fab\Media\FileUpload\ImageOptimizer::getInstance()->add('Fab\Media\FileUpload\Optimizer\Resize');

Permission Management

Permissions management is about controlling accessibility of a file. Permissions can be defined on each file under tab "Access" where to connect a File to a Frontend Group.

https://raw.github.com/fabarea/media/master/Documentation/Manual-05.png

Notice Media delegates file permission to third party extensions, such as extension naw_securedl. On the long term it should be considered to be used a secure local driver, however.

Basic Metadata Extractor

As a basic metadata extractor service, Media will set a title when a file is uploaded or whenever the files get indexed through the Scheduler task. The metadata title is basically derived from the file name e.g. my_report.pdf will results as My report. This should help your Editors coping with this metadata and save them some typing. Of course, the title will only be set, if no value exists beforehand.

media's People

Contributors

fabarea avatar fsaris avatar loco8878 avatar lorenzulrich avatar markuspoerschke avatar mbrodala avatar nxpthx avatar ohader avatar pniederlag avatar powerkiki avatar salthense avatar stissot avatar tbsschmdt avatar tobenschmidt avatar wdbmh avatar xperseguers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

media's Issues

updateRefIndexTable($tableName, $id); Response can be boolean in TYPO3 6.2.11

Two Hooks in the media ext. use the method

$refIndexObj->updateRefIndexTable($tableName, $id);

from the core in hooks and make strong constraints that its response is an array. But since TYPO3 6.2.11 it can also be boolean (FALSE). As a result saving a document with FAL relations can lead to a fatal error if no relations were found.

The method is used in Classes/Hook/DataHandlerHook.php in lines 72 and 99. Adding a simple

if (FALSE === $indexes) $indexes = array();

solves the issue but I think the real issue is in the core.

Missing data-uid in AudioThumnailProcessor and VideoThumbnailProcessor

The "data-uid" is missing in the anchor-tag (renderAnchorTag()) for audio and video files.
Following a patch file content to solve this issue:

Index: AudioThumbnailProcessor.php
--- AudioThumbnailProcessor.php Base (BASE)
+++ AudioThumbnailProcessor.php Locally Modified (Based On LOCAL)
@@ -96,10 +96,11 @@

        $file = $this->getFile();

-       return sprintf('<a href="%s%s" target="%s">%s</a>',
+       return sprintf('<a href="%s%s" target="%s" data-uid="%s">%s</a>',
            $this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(TRUE),
            $this->thumbnailService->getAppendTimeStamp() ? '?' . $file->getProperty('tstamp') : '',
            $this->thumbnailService->getTarget(),
+           $file->getUid(),
            $result
        );
    }
Index: VideoThumbnailProcessor.php
--- VideoThumbnailProcessor.php Base (BASE)
+++ VideoThumbnailProcessor.php Locally Modified (Based On LOCAL)
@@ -97,10 +97,11 @@

        $file = $this->getFile();

-       return sprintf('<a href="%s%s" target="%s">%s</a>',
+       return sprintf('<a href="%s%s" target="%s" data-uid="%s">%s</a>',
            $this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(TRUE),
            $this->thumbnailService->getAppendTimeStamp() ? '?' . $file->getProperty('tstamp') : '',
            $this->thumbnailService->getTarget(),
+           $file->getUid(),
            $result
        );
    }

Can't choose images from RTE integration - instead edit mode opens

While using media within normal images I can select an image by clicking on it or choosing the row action. When I try to do the same within the RTE integration I get the image edit mode, where I can crop the image. I'm unable to select the image. Also I don't have the ability to choose several images and use the row action method.

update content hook in draft workspace causes problems

When you create a content element with images in draft workspace (i.e. other than live workspace), then you try to update it - you end up with whitescreen.
Following exception occurs:
Argument 1 passed to TYPO3\CMS\Media\Hook\DataHandlerHook::isSoftReferenceImage() must be of the type array, boolean given, called in .../typo3conf/ext/media/Classes/Hook/DataHandlerHook.php on line 205 and defined.

FilePermissionsAspect::respectFileMounts(...) not working, users can see all files of storage(s)

In current master (vidi and media) - at least with PHP 5.4 - users filemounts are not respected. If a user has a filemount he can see the whole storage. Constraints are passed by signalSlot to

protected function respectFileMounts(Query $query, $constraints) ...

and in the end happens this:

$constraints = $query->logicalAnd(
    $constraints,
    $constraintsRespectingFileMounts
);

This wont work, at least in PHP 5.4. The $constraints variable is not modified in any way.

Translate tools

Currently the tools (Duplicate finder etc.) are not translateable because the texts are not in an XLF file. This should be changed.

I'm just filing this report here to keep track and will pick it up to do it as soon as I have time.

Sorting by "Title" leads to wrong SQL query and Error 500

I tried to enable sorting by "Title" by modifying the TCA with this snippet:

$GLOBALS['TCA']['sys_file']['grid']['columns']['metadata.title']['sortable'] = TRUE;

The sorting arrows are now shown for the field "Title", but clicking on the arrows leads to a error 500 because of this wrong sql query:

SELECT DISTINCT
    sys_file.*
FROM
    sys_file
    LEFT JOIN
    sys_file_storage
    ON
        sys_file.storage=sys_file_storage.uid
        AND
        sys_file_storage.deleted=0
WHERE
    sys_file_storage.uid = '1'
ORDER BY
    sys_file_metadata.title
    ASC
LIMIT
    10

This exception is thrown:

#1247602160: Unknown column 'sys_file_metadata.title' in 'order clause': SELECT DISTINCT sys_file.* FROM sys_file LEFT JOIN sys_file_storage ON sys_file.storage=sys_file_storage.uid AND sys_file_storage.deleted=0 WHERE sys_file_storage.uid = '1' ORDER BY sys_file_metadata.title ASC LIMIT 10

Improve Duplicate Files finder

Improve usability:

  • Omit checkboxes for files that have references and thus cannot be deleted
  • Improve wording
  • Add a toogle check button

Uncaught TYPO3 Exception #1300096564: uid of file has to be numeric.

Reproduction

  1. In the Media selection Add Video e.g. (Content -> FCE -> Video)
  2. click on preview icon => error
  3. click edit image (label/title is wrong) => success

Uncaught TYPO3 Exception
#1300096564: uid of file has to be numeric. (More information)

InvalidArgumentException thrown in file
typo3/sysext/core/Classes/Resource/ResourceFactory.php in line 340.

8 TYPO3\CMS\Core\Resource\ResourceFactory::getFileObject("undefined")
addvideo

Implement editor friendly possibilty to search by title and description

AFAIK the only possibility to search by title or by description only is to use these search instruction:

metadata.title:foo

metadata.description:bar

IMHO this is not very intuitive. Editors will most probably try these two search instructions to filter by title or description:

title:foo

description:bar

[BUGFIX] Link image/file after editting metadata

When i'm relating a new or existing image to my contentelement, but first edit some metadata using the "Edit Metadata"-link inside the popup, the icon to relate the image disappears when i'm returning to the grid/list.

Is this a know issue? Is there a way to make it work ?

[FEATURE] Respect read-only mount points

TSConfig:

options.folderTree.altElementBrowserMountPoints = 1:/, 2:/test
  • Edit and delete icon should be hidden
  • Perhaps display it in a special way (light gray) in the Grid?

Scenario: As I user, I want to find all files with Usage 0 and delete them.
The permission stuff should be implemented in a reusable way (kind of service)

Category Records/ Category Tab in FAL/Image edit Form not displayed for BE editors

I cant find a permission constellation on a group to allow users the categories in media extensions.
If a image is uploaded and the metadata edited the categoires tab does not show.

BE Group for that users have , mount on some categories, has read and modify table categories for that matter.

As an admin there is no problem, the form displays and working just fine.

DataHandlerHook produces fatal error in workspace

When the user is in a workspace and saves a Text & Images CE, on saving a fatal error occurs:

[Tue May 19 15:55:34 2015] [error] [client 127.0.0.1] PHP Catchable fatal error:  Argument 1 passed to TYPO3\\CMS\\Media\\Hook\\DataHandlerHook::isSoftReferenceImage() must be of the type array, boolean given, called in /home/www-data/www/htdocs/typo3conf/ext/media/Classes/Hook/DataHandlerHook.php on line 215 and defined in /home/www-data/www/htdocs/typo3conf/ext/media/Classes/Hook/DataHandlerHook.php on line 248, referer: https://www.domain.tld/typo3/alt_doc.php?returnUrl=%2Ftypo3%2Fsysext%2Fcms%2Flayout%2Fdb_layout.php%3Fid%3D531&edit[tt_content][33122]=edit

Didn't have time to check it yet, but I will.

Different search results depending on backend user group

Hi,

we had the problem in a project that the admins could find all files via the search in the media module, but the other user groups couldn't.
Those files could be found with the normal file list. After opening the files there once, there also appeared in the search results in the media module.
These files also don't have any access restrictions.

Could this be solveable by running the indexing task?
Or is this problem related to something else?

Thanks,
Sebastian

[FEATURE] Generate thumbnails by batch

Add limit when generating thumbnails more or less the same way the Core does for salted passwords. Generating thumbnails is very consuming resource wise. Goal is to avoid monopolizing the CPU too long.

The new "related_files" field not working for non admin users

The creation of file references to existing files does not work if not logged in as 'admin'.
An "Access Denied" error is thrown when i try to add a file to "related_files" as a normal BE user.
I created a user group with all rights except 'admin' and it does not work.
Maybe anybody can reproduce this behavior?

[FEATURE] Add new Facet is_writable

Allow the User to filter by writable files. This would be convenient for mass actions such as mass-delete which is only allowed for "writable" files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.