In case my recent questions have not made it abundantly clear, I am trying my hand at theme creation. Among the many other things that I am still figuring out are image sizes. Specifically add_image_size(...)
. I know I can use it to tell WordPress the sizes to make default images and so forth. Can I do that with an asset in my theme?
In my theme, I have an assets folder which contains a 1200x1200 image for use as a default in a range of cases. One part of my theme calls for images 140x140. Now, I could push that huge file into the src
for an image but it would be kinder on page load times if I resized it.
The do it myself hack would be to open GIMP and make one image for every size I can possibly imagine wanting.
Given I'm changing things all the time, I would rather let WordPress do that for me. Can I do that? If so how?
In case my recent questions have not made it abundantly clear, I am trying my hand at theme creation. Among the many other things that I am still figuring out are image sizes. Specifically add_image_size(...)
. I know I can use it to tell WordPress the sizes to make default images and so forth. Can I do that with an asset in my theme?
In my theme, I have an assets folder which contains a 1200x1200 image for use as a default in a range of cases. One part of my theme calls for images 140x140. Now, I could push that huge file into the src
for an image but it would be kinder on page load times if I resized it.
The do it myself hack would be to open GIMP and make one image for every size I can possibly imagine wanting.
Given I'm changing things all the time, I would rather let WordPress do that for me. Can I do that? If so how?
Share Improve this question asked Jul 1, 2019 at 3:19 Matthew Brown aka Lord MattMatthew Brown aka Lord Matt 1,0683 gold badges13 silver badges34 bronze badges1 Answer
Reset to default 0Images sizes are only relevant for uploads in the media library. If you have assets in your theme then you need to include whichever sizes are needed for how they're used in the theme.
Since end users can't choose your theme's bundled images to place wherever they want, you don't need every possible size. You'll only need the sizes that you use.