Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to make it so that WP will create another size image for me, but only when the image is uploaded via the Thickbox, and only when it will be attached to a certain ID.

Does anybody know how to do this?

The following works, but will create an image of that size for every upload, which is just inefficient.

add_action('after_setup_theme', 'set_image_upload_size');
function set_image_upload_size(){

    if(!{is Thickbox upload} || !{is attached to page 6838}) : // Don't know how to check this...
        return false;
    endif;

    /** Add an upload size for the footer images */
    add_image_size('footer-logo', 60, 40, false);

}
share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

There is no solution for this as of WP 3.5. There are a couple of core tickets about introducing the ability defer the generation of specific images sizes on the fly rather than at upload time to prevent the generation of multiple images that will never be used. However, they are far from being included in core at this point. See http://core.trac.wordpress.org/ticket/15311 and http://core.trac.wordpress.org/ticket/22100.

share|improve this answer
1  
Well that's a real shame, looks like a fair few other people think it would be a good idea. Thanks for your reply. –  David Gard Dec 20 '12 at 16:45
add comment

Have a look at this proposed solution. It's an on the fly resizing function.

It's actually taken from the ticket prettyboymp posted in the previous answer.

share|improve this answer
    
Thanks, I'll have a look, but I think I didn't go for it initially as it's probably a little overkill for what I need. –  David Gard Mar 1 '13 at 21:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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