Description
SrcSet responsive images for WordPress allows you to assign a SrcSet group to an image size within WordPress (e.g. medium or large). Any image within a post or page using that image size will have the SrcSet group’s attribute applied to it resulting in responsive images using the srcset attribute.
Why use SrcSet?
The srcset attribute is fully supported by most modern mobile devices. Where the attribute shines is allowing developers and content creators to eaily create responsive images for WordPress, swapping out large images for smaller ones more suitable to the size of the devices screen. This allows for less overhead when loading a website, improving load times, and reducing the amount of bandwidth visitors have to consume to view the site.
How does TrueNorth SrcSet Plugin Help?
SrcSet responsive images for WordPress automates the generation of the srcset attribute for all images attached to or within a post/page’s content. SrcSet groups can be setup for any image size registered with WordPress and once setup all images using that image size (e.g. ‘medium’) will have that SrcSet group’s attribute added to the img tag. No short codes, in fact no coding required at all!
What about all my existing post images?
SrcSet responsive images for WordPress comes with a Regeneration tool which will search all your posts and pages (including custom post types) find any images using sizes which have SrcSet groups and automatically add the srcset attribute to each one!
Verified contrib2dev project #d0ba1bfb7d445e852945ceaf0492e4ff. Support this project on contrib2dev.com.
Installation
- Upload to the
/wp-content/plugins/
directory - Activate the plugin through the ‘Plugins’ menu in WordPress
- Go to Tools > SrcSet Settings and create a new SrcSet group under the ‘General’ options tab and click ‘save changes’
- Click the group options tab on the left for your new SrcSet group.
- You want to create the srcset for all “large” images, so link this group to the ‘large’ image size be selecting it from the ‘Image Size Relationship’ drop down menu.
- We need to tell the browser which image size to use when the browser size changes, start by selecting the ‘small’ breakpoint from the ‘Select Breakpoint’ drop down menu.
- The default browser width for this breakpoint is 640px wide. We can leave this or use the ‘Breakpoint Width’ slider to customize this.
- Now we need to tell the browser which image size we want it to display at this breakpoint. Using the ‘Breakpoint Image Size’ drop down menu we can either select an image size already registered with WordPress OR we can create a new custom image size.
- !!Important!! If you create a custom image size for any of your breakpoints you will have to regenerate your image thumbnails using a plugin such as “Regen. Thumbnails”
- Complete steps 5 & 6 for each breakpoint (small, medium, large, large)
- Save your SrcSet group options.
- All existing posts/pages which have “large” images embedded in them will need to be converted to use your new SrcSet group.
- !!Warning!! Backup your database BEFORE this step as the process is irreversible!! Click the ‘Regeneration’ tab in the plugin options on the left. Click the ‘Regenerate srcset’ button and wait for the process to complete. Now all your existing posts using “large” images are now using your SrcSet group!
- Now whenever a user adds an image using the “large” size into a post/page content, the img html tag will also have your SrcSet group attribute added to it automatically!
Uninstall
- Go to Tools > SrcSet Settings
- Click “Regeneration” tab on the left of options page
- Select “Uninstall srcset” from dropdown option
- !!Warning!! Backup your database BEFORE this step as the process is irreversible!! Click the ‘Regenerate srcset’ button
- You can now uninstall the plugin
FAQ
- What are SrcSet groups?
-
SrcSet groups allow you to change the dimensions of images based on the current width of the user’s browser. When you assign a SrcSet group to an image size within WordPress (e.g. medium or large). Any image within a post or page using that image size will have the SrcSet group’s attribute applied to it.
For example, this ‘medium’ image…
img class=”alignnone size-medium wp-image-1264″ src=”http://www.domain.com/wp-content/uploads/2011/05/test_img-200×150.jpeg” alt=”test_img” width=”200″ height=”150″
Would change to something like thisβ¦
img class=”alignnone size-medium wp-image-1264″
src=”http://www.domain.com/wp-content/uploads/2011/05/test_img-200×150.jpeg”
srcset=”http://www.domain.com/wp-content/uploads/2011/05/test_img-125×125.jpeg 640w,
http://www.domain.com/wp-content/uploads/2011/05/test_img-200×150.jpeg 1024w,
http://www.domain.com/wp-content/uploads/2011/05/test_img.jpeg 1440w,
http://www.domain.com/wp-content/uploads/2011/05/test_img-1440×1200.jpeg 1506w”
alt=”test_img” width=”200″ height=”150″Note that the ‘srcset’ attribute had been added to the img tag and will instruct the browser to replace the image with different sizes at these breakpoints, 640w, 1024w, 1440w, and 1506w.
- I’ve set up an SrcSet group for an image size, but my images are not receiving the srcset attribute. What’s wrong?
-
If the images were already uploaded to the Media Library, you may have to regenerate thumbnails. We recommend using Regenerate Thumbnails for this.
- How do I uninstall and remove the srcset attributes from my images?
-
- Go to Tools > SrcSet Settings
- Click “Regeneration” tab on the left of options page
- Select “Uninstall srcset” from dropdown option
- !!Warning!! Backup your database BEFORE this step as the process is irreversible!! Click the ‘Regenerate srcset’ button
- You can now uninstall the plugin
- What are Image Groups?
-
SrcSet Groups give you a way to relate breakpoints to any specific image size (for example, medium). You can set specific breakpoints that align to your theme, and load in smaller versions of the same image. You can select existing image sizes (thunbmail, medium, large), custom image sizes created by themes or plugins, or add a custom image size with dimensions you create.
Note: If you use the Custom image size, remember to regenerate your thumbnails, otherwise these images will not exist, and therefore not be used within the srcset attribute.
- I just installed this plugin, but I have existing content with images that I’d like to add srcset attributes to. Can I do this?
-
Absolutely! In the srcset Settings area, there is a Regeneration page. This feature will go through all public posts (pages and posts by default), and regenerate the image tags of WordPress attachments in post content.
- I just installed a new theme, and the breakpoints I created for my SrcSet groups no longer align with my theme. What can I do?
-
First, take some time and adjust your SrcSet groups and their breakpoints. Once everything is set up properly to your liking, use Regenerate Thumbnails to create any new image sizes you’ve created. Then use the Srcset Regeneration tool.
- What about Retina support for srcset?
-
We intended on including the pixel density (x) support into the plugin. On further investigation, we realized it was not nearly as useful as the breakpoint (w) feature.
In future releases, we will be adding in the pixel density (x) feature support, and hope that it will become a more useful feature, to be combined with the breakpoint (w) feature.
- What benefits does this plugin give to my website?
-
The srcset attribute is a new HTML5 spec which allows us to specify multiple versions of the same image for various screen sizes. This means that you can serve smaller images for smaller screens and devices, which means your viewers will load your page much faster.
- Need help setting up a SrcSet Group?
-
In the plugin options under Tools > SrcSet Settings, click the ‘Help’ tab on the left and following the instructions for more examples.
Reviews
Contributors & Developers
“SrcSet Responsive Images for WordPress” is open source software. The following people have contributed to this plugin.
ContributorsTranslate “SrcSet Responsive Images for WordPress” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Changelog
1.0
Initial plugin launch.
1.1
Added uninstall option to regeneration tool to remove all instances of srcset from all images in all posts,pages,custom post types.
1.2
Added Picturefill.js expanding srcset support all browsers both desktop and mobile.
1.3
Altered the the filter used to hook into the_post_thumbnail()
and get_the_post_thumbnail()
. We now support wp_get_attachment_image()
and wp_get_attachment_image_src()
as well.
1.4
Updated Picturefill.js to v2.3.1, which fixes a JS error in Internet Explorer 8.
Fixed some strict standards and notices when passing dimensions to an image call, rather than registered image sizes.