J4.x

Difference between revisions of "Adaptive Images for Media Manager"

From Joomla! Documentation

(Changed 'Extsention' to 'Extension' and other markup changes.)
 
Line 23: Line 23:
 
* <translate><!--T:11--> If an author deletes the original image from the media manager, its resized image and the focus points are deleted too.</translate>
 
* <translate><!--T:11--> If an author deletes the original image from the media manager, its resized image and the focus points are deleted too.</translate>
  
<translate><!--T:12--> '''''Note: ''''' To Enable this Extsention, the administrator has to enable two plugins from the plugin's extension manager:</translate>
+
<translate><!--T:12--> '''''Note: ''''' To Enable this Extension, the administrator has to enable two plugins from the plugin's extension manager:</translate>
 
<translate><!--T:13-->
 
<translate><!--T:13-->
 
# Media-Action: Focus Plugin  
 
# Media-Action: Focus Plugin  
Line 35: Line 35:
  
 
<translate>
 
<translate>
 
 
==How to set focus points for a particular image?== <!--T:15-->
 
==How to set focus points for a particular image?== <!--T:15-->
 
</translate>
 
</translate>
 
# <translate><!--T:16--> Go to the Media Manager, locate the image you want to add focus points to.</translate>{{-}}[[File: NMM edit images-<translate><!--T:17--> en</translate>.png|center|800px]]
 
# <translate><!--T:16--> Go to the Media Manager, locate the image you want to add focus points to.</translate>{{-}}[[File: NMM edit images-<translate><!--T:17--> en</translate>.png|center|800px]]
# <translate><!--T:18--> Edit that image, you would be redirected to the new window, go to Focus tab.</translate>{{-}}[[File:Edit image-<translate><!--T:19--> en</translate>.png|center|800px]]
+
# <translate><!--T:18--> Edit that image. You will be redirected to the new window. Go to Focus tab.</translate>{{-}}[[File:Edit image-<translate><!--T:19--> en</translate>.png|center|800px]]
# <translate><!--T:20--> Now Select the focus area of the image, with the help of editor provided.</translate>{{-}}[[File: Focus Tab-<translate><!--T:21--> en</translate>.png | center|800px]]
+
# <translate><!--T:20--> Now Select the focus area of the image with the help of editor provided.</translate>{{-}}[[File: Focus Tab-<translate><!--T:21--> en</translate>.png | center|800px]]
# <translate><!--T:22--> After setting up the area, Save and Close the editor, you would be redirected back to the media manager.</translate>{{-}}[[File:Parameters-<translate><!--T:23--> en</translate>.png|center|800px]]
+
# <translate><!--T:22--> After setting up the area, ''Save and Close'' the editor. You will be redirected back to the Media Manager.</translate>{{-}}[[File:Parameters-<translate><!--T:23--> en</translate>.png|center|800px]]
 
# <translate><!--T:24--> Now just add that image normally to your article. ''Bosh...!! Your image is responsive while preserving the important section of that image.''</translate>
 
# <translate><!--T:24--> Now just add that image normally to your article. ''Bosh...!! Your image is responsive while preserving the important section of that image.''</translate>
  
 
<translate>
 
<translate>
 
 
==Adding Multiple Focus== <!--T:25-->
 
==Adding Multiple Focus== <!--T:25-->
 
</translate>
 
</translate>
# <translate><!--T:26--> Follow the basic step to set the initial focus points.</translate>
+
# <translate><!--T:26--> Follow the basic steps to set the initial focus points.</translate>
# <translate><!--T:27--> Now in the upper right corner of the plugin you will find a drop-down menu with different widths mentioned.</translate>{{-}}[[File:Different Focus-<translate><!--T:28--> en</translate>.png|center|800px]]
+
# <translate><!--T:27--> In the upper right corner of the plugin, find a drop-down menu with different widths displayed.</translate>{{-}}[[File:Different Focus-<translate><!--T:28--> en</translate>.png|center|800px]]
 
# <translate><!--T:29--> Select a width and then select its focus point in the focus editor.</translate>
 
# <translate><!--T:29--> Select a width and then select its focus point in the focus editor.</translate>
# <translate><!--T:30--> Save and close the tab.</translate>
+
# <translate><!--T:30--> ''Save & Close'' the tab.</translate>
  
 
<translate>
 
<translate>
 
+
==Adding Custom Widths== <!--T:31-->
==Adding custom widths== <!--T:31-->
 
 
</translate>
 
</translate>
# <translate><!--T:32--> Go to plugin's extension manager, look for '''Media-Action Focus'''.</translate>{{-}} [[File:Plugin extension manager-<translate><!--T:33--> en</translate>.png|center|800px]]
+
# <translate><!--T:32--> Go to plugin's extension manager. Look for ''Media-Action Focus''.</translate>{{-}} [[File:Plugin extension manager-<translate><!--T:33--> en</translate>.png|center|800px]]
# <translate><!--T:34--> Now add new widths over here, and save the plugin.</translate>{{-}}[[File:Add Widths-en.png|center|800px]]{{-}}[[File:Enter Widths-<translate><!--T:35--> en</translate>.png|center|800px]]
+
# <translate><!--T:34--> Add the new widths here and save the plugin.</translate>{{-}}[[File:Add Widths-en.png|center|800px]]{{-}}[[File:Enter Widths-<translate><!--T:35--> en</translate>.png|center|800px]]
# <translate><!--T:36--> You would be noticing those widths in the '''Focus''' tab.</translate>{{-}}[[File: Custom widths-<translate><!--T:37--> en</translate>.png|center|800px]]
+
# <translate><!--T:36--> You will notice those widths in the ''Focus'' tab.</translate>{{-}}[[File: Custom widths-<translate><!--T:37--> en</translate>.png|center|800px]]
  
 
<translate>
 
<translate>
 
+
==Deleting the Previously-Set Focus Point== <!--T:38-->
==Deleting the previous set focus point== <!--T:38-->
 
 
</translate>
 
</translate>
<translate><!--T:39--> '''Note: ''' This will delete all the previously saved focus and resized images of the original image generated by the plugin.</translate>
+
<translate><!--T:39--> '''Note ''' This will delete all previously saved focus and resized images of the original image generated by the plugin.</translate>
# <translate><!--T:40--> Go to the '''Focus tab''' in the '''Edit Image'''.</translate>
+
# <translate><!--T:40--> Go to the ''Focus tab''' in ''Edit Image''.</translate>
 
# <translate><!--T:41--> In the lower right of the screen there is a delete focus button.</translate>
 
# <translate><!--T:41--> In the lower right of the screen there is a delete focus button.</translate>
# <translate><!--T:42--> After deleting the previous focus reload the page or hit cancel to go back to media-manager</translate>
+
# <translate><!--T:42--> After deleting the previous focus, reload the page or hit ''Cancel'' to go back to the Media Manager</translate>
 
[[File:Delete Focus Button-<translate><!--T:43--> en</translate>.png|center|800px]]
 
[[File:Delete Focus Button-<translate><!--T:43--> en</translate>.png|center|800px]]
 +
 
<translate>
 
<translate>
 
 
==Workflow== <!--T:44-->
 
==Workflow== <!--T:44-->
 
</translate>
 
</translate>
 +
 
<translate><!--T:45--> This Extension consists of two independent plugins.</translate>  
 
<translate><!--T:45--> This Extension consists of two independent plugins.</translate>  
  
Line 79: Line 76:
 
===Focus Plugin=== <!--T:46-->
 
===Focus Plugin=== <!--T:46-->
 
</translate>
 
</translate>
<translate><!--T:47--> 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 <tt>AdaptiveImageController.php</tt>. 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 <tt>/media/focus</tt>. Nomenclature of resized images is <tt>(resize image width)_(base64 encoded full path of the image).</tt></translate>
+
<translate><!--T:47--> This is a Media Action plugin. It provides the user interface 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''. When satisfied with the focus, select ''Save and Close'' which raises another AJAX request. This time new images are generated with an efficient algorithm and saved in the directory ''/media/focus''. The nomenclature of resized images is ''(resize image width)_(base64 encoded full path of the image).''</translate>
  
 
<translate>
 
<translate>
 
 
===Adaptive Image Plugin=== <!--T:48-->
 
===Adaptive Image Plugin=== <!--T:48-->
 
</translate>
 
</translate>
<translate><!--T:49--> 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).</translate>
+
<translate><!--T:49--> This is a Content plugin. If the focus of a particular image is being set in the currently opened article, 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).</translate>
  
 
<translate>
 
<translate>
Line 92: Line 88:
  
 
<translate>
 
<translate>
===Changing storage for focus points=== <!--T:51-->
+
===Changing Storage for Focus Points=== <!--T:51-->
 
</translate>
 
</translate>
<translate><!--T:52--> Currently, The focus area is being saved in JSON format in the file storage(<tt>JSONFocusStore</tt> Driver). This can be changed to any other storage by making a new driver class into <tt>Joomla\CMS\AdaptiveImage\</tt>.The driver class should implement <tt>Joomla\CMS\AdaptiveImage\FocusStoreInterface</tt> interface.</translate>
+
<translate><!--T:52--> The focus area is saved in JSON format in the file storage (''JSONFocusStore'' Driver). This can be changed to any other storage by making a new driver class into ''Joomla\CMS\AdaptiveImage\''. The driver class should implement the ''Joomla\CMS\AdaptiveImage\FocusStoreInterface' interface.</translate>
<translate><!--T:53--> <tt>JSONFocusStore</tt> driver class is implementing <tt>Joomla\CMS\AdaptiveImage\FocusStoreInterface</tt>. <tt>FocusStoreInterface</tt> has following methods declared:</translate>
+
 
 +
<translate><!--T:53--> The ''JSONFocusStore'' driver class is implementing ''Joomla\CMS\AdaptiveImage\FocusStoreInterface''. ''FocusStoreInterface'' has the following methods declared:</translate>
  
1. <tt>setFocus($dataFocus, $width, $imgSrc)</tt>
+
1.''setFocus($dataFocus, $width, $imgSrc)''
: <translate><!--T:54--> This method stores/updates the focus area into the storage.</translate>
+
: <translate><!--T:54--> This method stores/updates the focus area.</translate>
:* <translate><!--T:55--> <tt>$dataFocus</tt> It has the dimensions of the focus area. It is an array with keys <tt>box-left</tt>, <tt>box-top</tt>, <tt>box-width</tt>, <tt>box-height</tt>.</translate>
+
:* <translate><!--T:55--> ''$dataFocus'' has the dimensions of the focus area. It is an array with keys ''box-left'', ''box-top'', ''box-width'', ''box-height''.</translate>
:* <translate><!--T:56--> <tt>$width</tt> It is the size of image for which the focus area is being stored.</translate>
+
:* <translate><!--T:56--> ''$width'' is the size of image for which the focus area is being stored.</translate>
:* <translate><!--T:57--> <tt>$imgSrc</tt> It is the full path of the image corresponding to the focus area.</translate>
+
:* <translate><!--T:57--> ''$imgSrc'' is the full path of the image corresponding to the focus area.</translate>
2. <tt>getFocus($imgSrc, $width)</tt>
+
2. ''getFocus($imgSrc, $width)''
: <translate><!--T:58--> This method returns the focus area of the image. It return all the focus area associated with the image</translate>
+
: <translate><!--T:58--> This method returns all the focus area associated with the image</translate>
:* <translate><!--T:59--> <tt>$imgSrc</tt> It is the full path of the image corresponding to the focus area.</translate>
+
:* <translate><!--T:59--> ''$imgSrc'' is the full path of the image corresponding to the focus area.</translate>
:* <translate><!--T:60--> <tt>$width(optional)</tt> If the user want to take in the value of focus area for particular width then, it may be mentioned.</translate>
+
:* <translate><!--T:60--> ''$width(optional)'' If the user want to take in the value of focus area for particular width, it may be mentioned.</translate>
3. <tt>deleteFocus($imgSrc)</tt>
+
3. ''deleteFocus($imgSrc)''
: <translate><!--T:61--> It deletes all the focus associated with the image.</translate>
+
: <translate><!--T:61--> This method deletes all the focus associated with the image.</translate>
:* <translate><!--T:62--> <tt>$imgSrc</tt> It is the full path of the image corresponding to the focus area.</translate>
+
:* <translate><!--T:62--> ''$imgSrc'' is the full path of the image corresponding to the focus area.</translate>
  
 
<noinclude>
 
<noinclude>

Latest revision as of 15:49, 13 September 2022

Other languages:
Deutsch • ‎English • ‎Nederlands • ‎français • ‎português do Brasil • ‎svenska • ‎Ελληνικά
GSoC 2018
Adaptative Image for New Media Manager
Documentation
Gsoc2016.png
Joomla! 
4.x

Introduction[edit]

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[edit]

  • Provides an editor for showing different crops of an image based on viewport size. This plugin takes the information from the author, in a more intuitive manner.
  • Auto-Crops images according to the viewport of the client device.
  • The cropping is around the focus area selected by the author.
  • The author can select widths for which the images need to be cropped.
  • The author can select different focus for different devices.
  • The author can remove all the resized images and the previously set focus points for a particular image from within the focus editor.
  • If an author deletes the original image from the media manager, its resized image and the focus points are deleted too.

Note: To Enable this Extension, the administrator has to enable two plugins from the plugin's extension manager:

  1. Media-Action: Focus Plugin
  2. Content: Adaptive Image Plugin

Cropped Images[edit]

Original image with focus area
Resized Images for focus area mentioned

How to set focus points for a particular image?[edit]

  1. Go to the Media Manager, locate the image you want to add focus points to.
    NMM edit images-en.png
  2. Edit that image. You will be redirected to the new window. Go to Focus tab.
    Edit image-en.png
  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 will be redirected back to the Media Manager.
    Parameters-en.png
  5. Now just add that image normally to your article. Bosh...!! Your image is responsive while preserving the important section of that image.

Adding Multiple Focus[edit]

  1. Follow the basic steps to set the initial focus points.
  2. In the upper right corner of the plugin, find a drop-down menu with different widths displayed.
    Different Focus-en.png
  3. Select a width and then select its focus point in the focus editor.
  4. Save & Close the tab.

Adding Custom Widths[edit]

  1. Go to plugin's extension manager. Look for Media-Action Focus.
    Plugin extension manager-en.png
  2. Add the new widths here and save the plugin.
    Add Widths-en.png
    Enter Widths-en.png
  3. You will notice those widths in the Focus tab.
    Custom widths-en.png

Deleting the Previously-Set Focus Point[edit]

Note This will delete all previously saved focus and resized images of the original image generated by the plugin.

  1. Go to the Focus tab' in Edit Image.
  2. In the lower right of the screen there is a delete focus button.
  3. After deleting the previous focus, reload the page or hit Cancel to go back to the Media Manager
Delete Focus Button-en.png

Workflow[edit]

This Extension consists of two independent plugins.

Focus Plugin[edit]

This is a Media Action plugin. It provides the user interface 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. When satisfied with the focus, select Save and Close which raises another AJAX request. This time new images are generated with an efficient algorithm and saved in the directory /media/focus. The nomenclature of resized images is (resize image width)_(base64 encoded full path of the image).

Adaptive Image Plugin[edit]

This is a Content plugin. If the focus of a particular image is being set in the currently opened article, 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[edit]

Changing Storage for Focus Points[edit]

The focus area is saved in JSON format in the file storage (JSONFocusStore Driver). This can be changed to any other storage by making a new driver class into Joomla\CMS\AdaptiveImage\. The driver class should implement the Joomla\CMS\AdaptiveImage\FocusStoreInterface' interface.

The JSONFocusStore driver class is implementing Joomla\CMS\AdaptiveImage\FocusStoreInterface. FocusStoreInterface has the following methods declared:

1.setFocus($dataFocus, $width, $imgSrc)

This method stores/updates the focus area.
  • $dataFocus has the dimensions of the focus area. It is an array with keys box-left, box-top, box-width, box-height.
  • $width is the size of image for which the focus area is being stored.
  • $imgSrc is the full path of the image corresponding to the focus area.

2. getFocus($imgSrc, $width)

This method returns all the focus area associated with the image
  • $imgSrc is the full path of the image corresponding to the focus area.
  • $width(optional) If the user want to take in the value of focus area for particular width, it may be mentioned.

3. deleteFocus($imgSrc)

This method deletes all the focus associated with the image.
  • $imgSrc is the full path of the image corresponding to the focus area.