1

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.

5
  • 1
    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
    – Tom J Nowell
    Commented Jan 31, 2018 at 19:02
  • 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");
    – Martin
    Commented Jan 31, 2018 at 19:15
  • 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
    – Tom J Nowell
    Commented Jan 31, 2018 at 20:35
  • 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.
    – Martin
    Commented Jan 31, 2018 at 20:49
  • I found a similar topic here. wordpress.stackexchange.com/questions/166703/… Unfortunately the code does not work anymore. Any hints on how it can be altered to my case?
    – Martin
    Commented Jan 31, 2018 at 21:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.