User tests: Successful: Unsuccessful:
Pull Request for the tasks of the first evaluation period of Media Manager.
Sometimes users have to wait more than 3 seconds for an image to get loaded while it unnecessarily wastes their cellular data. This is simply because the image that is being downloaded has a way bigger size than their mobile device and it is just shrunk by CSS to fit into it. So how can we fix this? By using the good old srcset and sizes attributes. These attributes allow us to display the right image for the right screen size.
In this part of the project, I made sure that every single image that gets inserted into the website content has its different-sized versions which are generated and set to the srcset attribute on the fly. In addition, the breakpoints are fully customizable so that it’s content authors who decide which size of an image to display on which screen.
Implement generateMultipleSizes function. Refactored the generateThumbs
function and its tests for creating generateMultipleSizes
function which generates different sized versions of a given image once users complete all operations on the image in content editors and the “Save” button gets clicked.
Implement createMultipleSizes function. Refactored the createThumbs
function and its tests for creating createMultipleSizes
function which takes different sizes of an image to be generated as a parameter and calls generateMultipleSizes
function on them. Once the images are generated, this function stores them in the responsive directory of the folder where the original image is stored.
Implement deleteMultipleSizes function. Added a method that finds and deletes responsive versions of an image with specified sizes and creation method.
Add helper functions for generating content and form images. Developed multiple functions for handling the image and attributes creation for content and form images. generateFormResponsiveImages
and generateContentResponsiveImages
get images as parameters, filter them, and calls createMultipleSizes
on them. On the other hand, generateSrcset
and generateSizes
methods create and return corresponding attributes with provided sizes. addContentSrcsetAndSizes
is used to insert or update existing attributes for content images. Last but not least, getSizes
is the one for getting the right sizes to generate.
Add "Content - Responsive Images" plugin. Implemented a new plugin for using responsive images functionality in every component where it's needed. Images and attributes are generated and inserted into the web content by using the onContentBeforeSave
and onContentAfterSave
event methods.
Add a new option to override default image sizes. Added a plugin option that ensures that it's possible to customize the default responsive image sizes. Newly specified sizes apply to all the images in the web content.
Add a new option to set different size options for form images. Users can override the default sizes by using the plugin options - the sizes they specify become the new default, but what if they want to set different sizes for each image separately? Added form controls for individual form images to override the default plugin options.
NOTE: Option for customizing content responsive image sizes will be added until the final evaluation period (August 16 - August 23).
Activate the plugin. Go to System -> Plugins -> Content-Responsive Images and activate the plugin. You can define a new default for image sizes by using the "custom sizes" form field. If not, images will be generated with 800x600, 600x400, 400x200.
Insert images and save. Go to any component where it's possible to add images to web content. For example, create or edit an existing article by inserting a content or form image into it. Sizes for form images can be customized by using the "Custom responsive sizes" option.
As you can see, the image size dropped from 221 kB to 41.3 kB as we decreased the screen size which basically means a faster website and with lower bandwidth usage.
MediaHelper
and Image
class methods must be added or updated.
Special thanks to my mentors (@sebenns, @fancyFranci, @GeraintEdwards, @shivamdiehard, Chris Keen) and @bembelimen for assisting me with the project.
Hello it will be a great adding
but maybe you can extend it with sub-type of image
1 adding a repeatable field with title
2 adding your custom field size
3 adding methode of rezize (cropped rezized)
it will be good use can create his own preset like
=> large 1280_800 rezized => medium 800_600 cropped
ect ... and any user or template provider can create and choose is format
Thanks, that's a great idea!
Category | ⇒ | Administration com_admin com_banners com_categories com_contact com_content com_media com_newsfeeds com_tags Language & Strings Front End SQL Installation |
Please discuss with your mentors but you have not refactored createthumbs
and generatethumbs
What you have done is to remove them completely and you can not do that without first deprecating them etc etc
Labels |
Added:
?
?
|
Category | Administration com_admin com_banners com_categories com_contact com_content com_media com_newsfeeds com_tags Language & Strings Front End SQL Installation | ⇒ | Administration com_admin com_banners com_categories com_contact com_content com_newsfeeds com_tags Language & Strings Front End SQL Installation Postgresql Layout |
Thank you for your review @brianteeman! I fixed the issues that you've specified. As for the createThumbs
and generateThumbs
functions, I will discuss them with my mentors and push a new commit with the updated version,
Labels |
Added:
?
Removed: ? |
Labels |
Added:
?
Removed: ? |
Labels |
Added:
?
?
Removed: ? ? |
Labels |
Added:
?
Removed: ? |
Labels |
Added:
Language Change
Removed: ? |
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-08-20 10:22:05 |
Closed_By | ⇒ | eyvazahmadzada | |
Labels |
Added:
?
Removed: ? |
First, thanks for the effort.
I only tested it on local server, the issue i have is that it slow the site a lot to generate the images. from 1 sec of page load to 6.5 sec or more.
Hello it will be a great adding
but maybe you can extend it with sub-type of image
1 adding a repeatable field with title
2 adding your custom field size
3 adding methode of rezize (cropped rezized)
it will be good use can create his own preset like
=> large 1280800 rezized
=> medium 800600 cropped
ect ... and any user or template provider can create and choose is format