Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I'm feeding a mobile app from WP. I want the images uploaded to be rescaled like x0.5, x0.3 .
add-image-size doesn't give me scaling functionality, only resizing by pixel.
Any Idea? thx.
Have you considered multiplying the pixel size by 0.5 and calling it largex0.5? WP doesn't resize images on the fly, only when things are uploaded, else pages would take a long time to generate
Thanks for your reply Tom. I was unclear in that. Yes the images should be resized on upload. I would be perfectly happy with the add-image-size function if you could specify a scale factor instead of pixel values. Maybe in the crop parameter. Like: add_image_size( '[email protected]', 0.5, 0.5, "scale");
ah, add_image_size doesn't support that, but if it did, I imagine you'd get strange results in your mobile app as different sized images were uploaded. Instead, set an upper limit with maximum dimensions and assign that as an image size. That's what applications such as instagram do. They might then register a size half as big and use that for non-retina devices. Otherwise, a 24MP image will still be 12MP if it's scaled by half, and a 2MP image will only be 1MP, leading to one image 12x the size of the other
I understand. In my case I use an acf plugin that crops the uploaded image in a predifined size. It has a great UI and works well. Out comes a cropped version of the image in the right size. Through add-image-size all other sizes are also created from this. The app needs quiet a few different sizes and each need different scales. That creates a lot of unused images. With a simple scaling function this could be just perfect.
largex0.5
? WP doesn't resize images on the fly, only when things are uploaded, else pages would take a long time to generateadd_image_size
doesn't support that, but if it did, I imagine you'd get strange results in your mobile app as different sized images were uploaded. Instead, set an upper limit with maximum dimensions and assign that as an image size. That's what applications such as instagram do. They might then register a size half as big and use that for non-retina devices. Otherwise, a 24MP image will still be 12MP if it's scaled by half, and a 2MP image will only be 1MP, leading to one image 12x the size of the other