Support » Plugins » Hacks » Image upload / GDLib / WordPress hooks

  • Ok so I have a bit of an odd situation that I need help with. What I am trying to do with my custom plugin is have images that are uploaded for a custom post be stored in a special directory – which I have accomplished using the wp_handle_upload(). The thing is I also needed to have a new custom image size for the specific post type – which again I accomplished using add_image_size(). So far all of this is working perfectly. My next step has me stumped though…

    I need to run a bunch of GDlib processing on JUST the new image size I have created and named using the WordPress hooks. For sake of discussion I used add_image_size(‘google-marker’,100,100, false);

    Now I dont want to change anything about the other files WordPress creates based on the media settings. I just want to change ‘google-marker’ to have a border and a little arrow pointer (which I know how to do in GDlib already)… I just dont know how to hook into wordpress to intercept the default image resizing and create my own.

    Any pointers, help, links for things similer etc are all much appreciated.


Viewing 2 replies - 1 through 2 (of 2 total)
  • I should add that I know I can do this dynamically when the image displays but given the amount of images loading at once I think that going that approach is far more server intensive than just creating them on upload.

    Moderator bcworkz


    I’m unfamiliar with the precise data flow WP follows to create the various sizes, so this may be a bogus lead.

    It appears the hook you want is the ‘image_downsize’ filter. It is applied in wp-includes/media.php at lines 148 and 1386. Review the source code for specifics on how to return data. You should be able to discern if the image should be processed mostly just from the $size parameter passed from the sounds of things. Of course you would also need to check if the modified image file already exists, no point doing it more than once.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Image upload / GDLib / WordPress hooks’ is closed to new replies.