Adaptive Images for Media Manager: Difference between revisions
From Joomla! Documentation
No edit summary |
|||
| Line 73: | Line 73: | ||
===Adaptive Image Plugin=== | ===Adaptive Image Plugin=== | ||
This is a Content plugin. If the focus of a particular image is being set in the currently opened article then this plugin will add the <tt><picture></tt> element to that image and all the associated resized-images will be appended to it from <tt>/media/focus/</tt>. | This is a Content plugin. If the focus of a particular image is being set in the currently opened article then this plugin will add the <tt><picture></tt> element to that image and all the associated resized-images will be appended to it from <tt>/media/focus/</tt>. This plugin will also delete all the resized images if the original image is not found (or deleted). | ||
==Extending Extension== | ==Extending Extension== | ||
Revision as of 14:07, 29 July 2018
Adaptative Image for New Media Manager
Documentation

Introduction
The main objective of this extension is to preserve the important message associated with the image, by providing the user a way to add the focus area for the image. Images are being made responsive with the help of this extension. This extension is supported by the media-action plugin and the content plugin.
Features
- Provided a focus editor for taking in the focus information from the author, in a more intuitive manner.
- Auto-Cropping of the images according to the viewport of the client device.
- The cropping is done around the focus area selected by the author.
- Author can select particular widths for which the images need to be cropped.
- Author can select different focus for different devices.
- Author can also remove all the resized images and the previous set focus points for a particular image from the focus editor.
- If an author deletes the original image from the media manager, its resized image and the focus points would be deleted too.
Note: To Enable this Extention, Administrator has to enable two plugins from the plugin's extension manager:
- Media-Action: Smart Crop Plugin
- Content: Adaptive Image Plugin
Cropped Images


How to set focus points for a particular image?
1. Go to the Media Manager, locate the image you want to add focus points to.

2. Edit that image, you would be redirected to the new window, go to Smart Crop tab.

3. Now Select the focus area of the image, with the help of editor provided.

4. After setting up the area, Save and Close the editor, you would be redirected back to the media manager.

5. Now just add that image normally to your article. Bash...!! Your image got responsive while preserving the important section of that image.
Adding Multiple Focus
1. Follow the basic step to set the initial focus points.
2. Now in the upper right corner of the plugin you will find a drop-down menu with different widths mentioned.

3. Select a width and then select its focus point in the focus editor.
4. Save and close the tab.
Adding custom widths
1. Go to plugin's extension manager, look for Media-Action Smart Crop.

2. Now add new widths over here, and save the plugin.


3. You would be noticing those widths in the Smart Crop tab.

Deleting the previous set focus point
Note: This will delete all the previously saved focus and resized images of the original image generated by the plugin.
- Goto the Smart Crop tab in the Edit Image.
- In the lower right of the window there is a delete focus button.
- After deleting the previous focus reload the page or hit cancel to go back to media-manager

Workflow
This Extension consist of two independent plugins.
Smart Crop Plugin
This is a Media-Action plugin. It is providing the UI for managing the focus points. It takes in the focus points from the user and saves it into the file storage by sending an AJAX request to the controller AdaptiveImageController.php. Finally, when the author is satisfied with the focus he hit Save and Close which raises another AJAX request, this time new images are generated with an efficient algorithm and save them into the directory /media/focus. Nomenclature of resized images is (resize image width)_(base64 encoded full path of the image).
Adaptive Image Plugin
This is a Content plugin. If the focus of a particular image is being set in the currently opened article then this plugin will add the <picture> element to that image and all the associated resized-images will be appended to it from /media/focus/. This plugin will also delete all the resized images if the original image is not found (or deleted).
Extending Extension
Changeing storage for focus points
Currently, The focus points are being saved in JSON format in the file storage. This can be changed to any other storage by making a new driver class into Joomla\CMS\AdaptiveImage\.The driver class should implement Joomla\CMS\AdaptiveImage\FocusStoreInterface interface.