So let’s say the client uploads an image in admin using the media gallery, for a blog post. I would then like WordPress to generate a smaller size of that same image. However I am unsure how to do this.
I know there is a function called add_image_size(); however I am unsure how I would implement this into my theme, and have a couple of questions about it….
1. Does add_image_size(); actually reduce file size as opposed to just dimensions?
From what I know, whenever a user uploads an image, small versions are created automatically, and you can define these yourself in functions.php. It does reduce the image dimensions, so yeah, the file size also changes.
Whenever the user uploads an image (ANY image, not just the featured image), three other images are created with the sizes 1280×960, 640×480 and 320×240. Of course you can edit all this in functions.php. There probably is one of those already, but you can add as many as you like.
So no, the user does not have to create and upload various sizes of images.
I’ve not yet seen any way to make it completely dynamic where it grabs the smaller file when using smaller screens. The method I typically use is to simply make anything at that phone size scale at max-width:100% with a height of auto. These are for just the normal images on the site – the Smashing article addresses the post image sizing specifically.
I also use `max-width: 100%; height: auto !important;`. Images should be compressed before adding them to a site regardless. There may be a plugin your client can use where he/she just clicks a button and it compresses the image for them.
Thanks guys, I am using max-width: 100% however unfortunately using just this alone is not a viable solution.
I am working on an image-heavy responsive site which is tailored for mobiles to 27″ iMacs! There are a few images almost full screen, so I’m sure you can appreciate the difference in file size for that range, even if compressed to the max.
I haven’t had a chance to look into this properly just yet but will update this post when I do.
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic.
*May or may not contain any actual "CSS" or "Tricks".