3.2.1releasedMedia Library

Media management extension for Symphony CMS. Edit images and manage upload file.

Clone URLhttps://github.com/pixelninja/media_library.git

Add as a submodulegit submodule add https://github.com/pixelninja/media_library.git extensions/media_library --recursive

Compatibility

2.x.x2.1.x2.2.x2.3.x2.4.x2.5.x2.6.x2.7.02.7.12.7.22.7.32.7.42.7.52.7.62.7.72.7.82.7.92.7.10
NoNoNoNoNoNoNo3.2.13.2.13.2.13.2.13.2.13.2.13.2.13.2.13.2.13.2.13.2.1

Readme

Media Library

This extension aims to be a one stop shop for asset management with Symphony CMS projects. You can view, delete, search, upload and manipulate files into the site uploads folder.

This also comes packaged with a field to replace the default upload field, where files can be uploaded or selected and attached directly to entries.

Upgrade Notes

3.0

If you are upgrading from a version lower than 3.0, this is a breaking change. File data is now output as nodes when previously they were attributes. Please check the debug carefully and update your xslt to match.**

Installation

  • Upload the /media_library folder to your Symphony /extensions folder.
  • Enable it by selecting "Media Library", choose Enable from the with-selected menu, then click Apply.

/workspace/uploads must exist. This is the directory within which this extension looks for files and subdirectories.

The json/tags.json file needs to be writable in order to attach tags to files. These are used for filtering within the Media Library.

The json/alts.json file needs to be writable in order to attach alt attributes to files.

Note that any extension updates will most likely clear the JSON files of any data. Always back these up first.

How to use

Firstly, set up the upload defaults in the preferences. These include items like image dimensions and file sizes.

There are two parts to this extension. The Library and the Field.

Media Library

You should see Media Library as a main nav item now. Clicking on the icon will take you to the Media Library page, clicking anywhere else will open the Media Library in a modal box.

Uploading a file

In the top right is an upload button. Clicking on this will slide down the drag and drop capable field.

If you have Doka enabled (more on this below), you will see 2 options: Image Editor and Multiple Upload. Use the toggle to switch out upload fields.

Image editor takes a single image file, and before uploading brings up edit options so you can manipulate the file.

Multiple Upload allows for multiple files of any type.

If you don't have Doka enabled, then you will only have the Multiple Upload option available to you.

Files will automatically upload after you have dropped or selected them, and then the list will refresh once all files have completed.

Directories

To the left is a Show Directories button. This toggles any sub directories within the uploads folder. Clicking on one will take you inside that folder and display any files within it. Clicking back, takes you back. Simples.

Files

Files are displayed in a list format. The name of the file is on the left, and any meta data is displayed in the middle. Actions are listed on the right.

Files are ordered chronologically, with the latest to be uploaded at the top.

Clicking tags will present an input box. Comma separated tags can be entered here, which become searchable using the filter input above the list of files. This will be output with the image path.

Clicking alt will present an input box. Type the alt text you wish to use for this image. This will be output with the image path.

Edit will open an instance of Doka allowing you to edit an existing image, and choose to rename it or overwrite it. This option won't appear if Doka isn't enabled.

Preview opens the file in a new tab.

Copy file URL copies the file path to the users clipboard.

Delete removes the file completely. Even if it's being used somewhere! Use with caution.

Media Library Field

This has been designed to replace the default upload field. It allows you to add a field to a section where an image from the Media Library can be attached. This way, an image can be used in multiple places instead of having to upload it multiple times. You can also add field specific file validation:

  • Validation Rule: same as other fields. Good for forcing the file type.
  • Media Ratio: This is primarily for images, as it forces an aspect ratio. For example, 3:2 will force landscape, 2:3 will force portrait and 1:1 will force square. There are presets you can choose from or you can manually type your own. They need to be colon separated integers.
  • Maximum File Size: This will check that the file is less than or equal to a set size. For example, an avatar is normally a small resolution so the file size might not need to be larger than 50KB, or a thumbnail might be slightly higher resolution but should be less than 100KB. This forces authors to upload images that are not too large for the web, keeping load times down. They must be integers with a unit type of B, KB, or MB.
  • Destination Directory: The folder to open by default, relative to the /workspace/uploads folder.
  • Allow selection of multiple files: This is useful when you need to attach multiple files to an entry, e.g in a gallery or a list of files to be downloaded. Selected files can be reordered with drag/drop.
  • When Allow Multiple has been selected, checkboxes will appear next to each file to allow rapid selection. Check the files you wish to attach, then click any of the select file(s) links

Image manipulation with Doka.js

To use Doka, you must purchase a licence and upload the files to a folder called doka in the root. I.e /doka/doka.min.js and /doka/doka.min.css. The extension looks for this file path to confirm Doka integration.

This plugin is great, as it gives authors the ability to upload an image and manipulate it to suit the needs. For example, they may upload an image for a hero image. Then they may upload the same image and crop it to use as a thumbnail. This means they don't need to use expensive or complicated editing software to make web ready imagery.

Read the documentation if you wish to modify settings and options.

TinyMCE Integration

Another useful tool is the ability to attach files within WYSIWYG text editors. For example, within news articles.

To use the media library within the TinyMCE editor, add this snippet to your TinyMCE javascript file within the init function:

file_picker_types: 'image media', file_picker_callback: function(callback, value, meta) { ml_source_input = callback; localStorage.setItem('add-to-editor', 'yes'); $('#nav .ml-link').trigger('click'); },

Now, when clicking the image or media icon within the editor, there will be a file icon next to the source field. Clicking this will open the media library, and instead of Copy file URL being an option, it will say add to editor. This will add the file source and the file name to the source and alt fields.

Wishlist

  • Add minimum/maximum file validation to multi mode
  • Check if a file is in use before permanently deleting it.

Version history

Requires Symphony 2.7.x

  • Only show select all of there is more than one file

Requires Symphony 2.7.x

  • Better 'Select All' UI, with ability to toggle all at once

Requires Symphony 2.7.x

  • Add ability to create directories

Requires Symphony 2.7.x

  • BREAKING CHANGE: Restructure the output into nodes instead of attributes. This was getting too large and unreadable, and nodes are easier to deal with within xslt

Requires Symphony 2.7.x

  • Re-work the subdirectories into a breadcrumb for easier visualisation and navigation

Requires Symphony 2.7.x

  • Add apache check for mod_expires module

Requires Symphony 2.7.x

  • Bug fix: JSON files are cached making it look like the Alts and Tags aren't being added. I have added an htaccess file to the JSON directory that overrides the cache and forces it to revalidate

Requires Symphony 2.7.x

  • Bug fix: file name was getting lost after the restructure of content.

Requires Symphony 2.7.x

  • Bug fix: Position of tag/alt inputs was behind submit button

Requires Symphony 2.7.x

  • Bug fix: Filtering has been broken since the structure changes of 2.1.5.

Requires Symphony 2.7.x

  • Bug fix: 'View' links on Media Library Fields were going to incorrect file URL after file had been replaced

Requires Symphony 2.7.x

  • Bug fix: row options were collapsing to a new line when tags or alt attributes were added. Add better flex rules.

Requires Symphony 2.7.x

  • Add resize utility to Doka
  • Stop rename prompt happening when Doka is escaped

Requires Symphony 2.7.x

  • Add ability to edit and replace/rename an existing file (must have Doka files loaded in)
  • Restructure file rows for better alignment/spacing

Requires Symphony 2.7.x

  • Bug fix: incorrect file path for JSON files in XML output

Requires Symphony 2.7.x

  • Better folder layout and naming

Requires Symphony 2.7.x

  • Add Alt attributes to images
  • Output Alt attributes and tags into page XML

Requires Symphony 2.7.x

  • Bug fix: remove event handlers on back/forwards directory click events on re-init of main function to prevent stacking of click events
  • Bug fix: better fasly declaration on undefined/null folder path

Requires Symphony 2.7.x

  • Bug fix: prevent events being called multiple times

Requires Symphony 2.7.x

  • Consistent styling for fields within the Primary column
  • Add a landscape and portrait ratio with relevant validation

Requires Symphony 2.7.x

  • Remove icon from navigation
  • Add scripts/styles from local source instead of calling them from unpkg.com as it's often slow to load

Requires Symphony 2.7.x

  • Allow multiple files to be selected at once when field allows it

Requires Symphony 2.7.x

  • Add a check for animated GIFs into FilePond transform process, if it is then don't apply transform which converts it to a PNG.

Requires Symphony 2.7.x

  • Media Fields within Modal boxes weren't opening because of the trigger call on a non existant nav item. I have fixed this by wrapping the loading of the ML into a function and calling that on click instead.

Requires Symphony 2.7.x

  • Add ability to define a destinition folder for file selection

Requires Symphony 2.7.x

  • Create field specific validation for image ratio and file size
  • Bug fix: validation didn't loop through data array and only validated first item. It now validates all files attached.
  • Add better Doka crop ratios
  • Redo the read me

Requires Symphony 2.7.x

  • Bug fix: delete button event wasn't triggering on AJAX loaded content
  • Bug fix: rogue colon in delete file function causing an error

Requires Symphony 2.7.x

  • Better define jQuery

Requires Symphony 2.7.x

  • Add missing Symphony::Configuration()->remove() from Uninstall function
  • Add File Size validation
  • Add Image Size validation

Requires Symphony 2.7.x

  • Add a file_exists check for the Doka files to prevent unecessary requests which fail

Requires Symphony 2.7.x

  • Type fix where min image height was being applied to max image height

Requires Symphony 2.7.x

  • Replace upload method with FilePond
  • Include Doka integration, if user has a licence
  • Add preferences pane for image editing options
  • Some styling changes for better flow
  • Automatically refresh list of files on completion of upload

Requires Symphony 2.7.x

  • Sanitize the file name when uploading to prevent special characters causing display issues with images

Requires Symphony 2.7.x

  • Sanitize the file name to prevent errors in XML output, specifically the name attribute

Requires Symphony 2.7.x

  • Update how multiple items are displayed
  • Add drag/drop for reording multiple items

Requires Symphony 2.7.x

  • Add ability for multiple files to be attached
  • Add default preview so something is always displayed

Requires Symphony 2.7.x

  • Bug fix where ML wouldn't trigger within AJAX loaded content (e.g within Entry Relationship Field content)

Requires Symphony 2.7.x

  • Add validation to Media Library field
  • Add a remove link to unattach files
  • Show video and audio previews
  • Have bigger previews in the Primary column

Requires Symphony 2.7.x

  • Add a Media Library Field to the section editor
  • The new field triggers the ML which allows for uploading/selecting a file to attach to an entry
  • Show a preview of the file if it's an image
  • Output the field in a datasource with relevant meta data

Requires Symphony 2.7.x

  • Add a tag count to the Tags link, and add hover state showing tag content
  • Ignore changes to the json file

Requires Symphony 2.7.x

  • Tagging bug fixes

Requires Symphony 2.7.x

  • Tagging bug fixes

Requires Symphony 2.7.x

  • Added ability to tag images, which are searchable

Requires Symphony 2.7.x

  • Update so deleting works within lightbox
  • Bug fixes

Requires Symphony 2.7.x

  • Remove unused plugins and add clipboard into extension js file for fewer requests
  • Add AJAX call for page fetching
  • Combine this plugin with TinyMCE plugin to work within editors

Requires Symphony 2.7.x

  • Removed Featherlite, and open previews in a new tab instead

Requires Symphony 2.7.x

  • Order files by date instead of name
  • Hide directories by default. A button has been added for toggling their visibility
  • Added an input for filtering files based on a keyword match

Requires Symphony 2.7.x

  • Restructured the way files are displayed
  • Added loads of features

Requires Symphony 2.7.x