Adaptative images
-
[ Moderator note: moved to Fixing WordPress. ]
Hello,
I am working on the optimization of the images of a wordpress site.
I defined several sizes in my functions.php file, via the add_image_size. However, I want to use the attributes “srcset” to managed the size of the images. I was wondering if I have to have several sizes of the same image or not (which involved to upload several pictures).
For example :
srcset= "cat.jpeg / cat-480.jpeg / cat-720.jpeg"
And for the attribute “size”, I just have to specified the condition about the device, right?
For example :
sizes="(max-width: 480px) 'small_size', (max-width: 720px) 'medium_size', (max-width: 1024px) 'larger_size'"
I have found the function wp_calculate_image_srcset, in media.php. So, I was wondering, if it will be a good way to write the others sizes after ‘format_313x194’ ?
<img src="<?php echo $aImg['sizes']['format_313x194']; ?>" alt="<?php echo $aImg['alt'] ?>" />
Thank you for your comments and answers. Havee a nice day!
- The topic ‘Adaptative images’ is closed to new replies.