3

There is a type of post on my blog which requires one extremely large image (such that it can be zoomed). I don't want to register a new image size, because I only need a certain small subset of images to have this large image size. I have managed to generate this additional large image and it sits alongside the other three "generated" images in the uploads directory, however since it is not registered with the Media Library, it does not get uploaded to the image CDN with W3 Total Cache.

Can anyone suggest a better approach to my problem? Or suggest how I might register that large image with the media library (without it automatically creating the other image sizes which would not be needed). Or is there perhaps a way to register an additional image size for only some images in my media library?

3
  • how do you get the image? Dec 5, 2013 at 10:52
  • @MarkKaplun I essentially use: image_make_intermediate_size($srcFilePath, $max_desired_width, $max_desired_height, $crop); This generates the large image at the desired dimension from an attachment. Obviously there is additional caching mechanisms such that it's only generated once but that's essentially it.
    – Willster
    Dec 5, 2013 at 12:10
  • One solution will be to add a checkbox in the wp uploader, then filter the resize and upload handler to only generate new image sizes for your "checked" uploads, but I don't know how wp will handle the other images with a missing size. Dec 12, 2013 at 19:20

1 Answer 1

2

Since you know the location of the image on the disk you can use wp_insert_attachment to insert your big image to the media library. By default this will generate also several smaller versions of the big image that you might not need but this is the easiest way to make all the media related plugins to be aware to your image.

1
  • I think your answer is certainly straight forward, but I thought there might be a nicer way. If no one further enlightens me I'll accept this.
    – Willster
    Dec 6, 2013 at 15:47

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.