Wednesday, 18 April 2018

How to add custom image sizes to your theme


I can’t stop praising WordPress when it comes to the conveniences it provides. While the approach it takes on things might not suit everyone, every time, for the most part its solutions to common issues are good enough. Once such example is images, and the creation of custom sizes from the originally uploaded one. WordPress’s approach sacrifices disk space and does any work needed at the time an image is uploaded. Intermediate image sizes are then ready to be served by WordPress or the web server, with no additional overhead.
Another approach would be to generate any intermediate sizes on the fly, only when and if needed. This minimizes disk space usage, but carries the overhead of checking whether the requested size exists on every request, and actually generating it if it doesn’t. This might sound like a good idea, especially if disk space is limited, but it’s only good under very specific circumstances, e.g. low traffic websites with limited disk space.
Anyhow, WordPress made its choice a long time ago and went with the former approach. So, let’s see how we can add and use our own image size in our child theme.
For the purposes of this tutorial, I’ll
Source: https://managewp.org/articles/17336/how-to-add-custom-image-sizes-to-your-theme



source https://williechiu40.wordpress.com/2018/04/18/how-to-add-custom-image-sizes-to-your-theme/

No comments:

Post a Comment