最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

media - How do I get WordPress to create resizes of a supplied default image in a theme?

programmeradmin2浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

Images 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.

发布评论

评论列表(0)

  1. 暂无评论