I am creating a responsive WordPress website with a mobile-first approach.
When my client uploads an image for a blog post, I would like WordPress to then generate smaller versions of the image (with a smaller file size!) which then get served to smaller screen sizes?
Even if the user has to upload several versions of the image themselves, this would still be a good solution.
I am aware there is a function called add_image_size, however I believe this only changes the dimensions of the image, and not the actual file size. The different file sizes are the most important thing here.
So is there any plugin or code I have to write to enable this?
I look forward to hearing any help or advice on this question.
Thanks
add_image_size does change the actual size of the image file.
What I hava tried:
When checking for the device type (iphone or tablet), you can use the custom images like this
I can’t sent you a screen shot since I don’t have the reputation needed. But you can see at the uploads folder, that the images entered with your custom dimensions, will have different size (at the disk), so they will consume different bandwidth. Smaller the dimensions, lesser the bandwidth.
The easiest way is using css
I use the following code to my site.
I hope the above css code can help you.
panos got it right. You can use add_image_size to create different size images for different purposes. To continue a bit further with your question, I want to add:
Once you’ve created different image sizes with add_image_size, you can serve them for different devices by using WordPress plugin Mobble (or any other php-based device recognition) http://wordpress.org/plugins/mobble
Just do a simple if else statement something like this: