So – at a client’s request, I am in need of being able to resize an image not the standard WordPress way… but from an image pulled-in from a theme option. I can’t simply use the custom_header area, as there will be two or three (I also have some options once the image is uploaded to let the user choose how the link should function (page, post, category, no link, external link, etc)). I’m using Options Framework Theme with great success and I can retrieve the image src just fine, it’s a matter of if this can somehow be used in combination with the add_image_size() function normally used for post thumbnails. I’d REALLY rather not go the timthumb route and stick with WordPress APIs (I know that’s a little contradictory to what I am doing in the first place…). Any help would be greatly appreciated. Thanks!
Leave a Reply
You must be logged in to post a comment.
Re-size WordPress images on the fly using built-in WordPress functions.
Use the
vt_resize
function to dynamically re-size WordPress images located in a custom field, featured image, uploads directory, NextGen Gallery WordPress plugin, or even an external link to an offsite image.It is very simple to use, just copy/paste the code below into your WordPress theme’s
functions.php
file of your currently activated WordPress theme.Then, where ever you need to re-size an image on the fly, just place a call to that function following the parameter usage explained in the comments of the function.
Here is an example of automatically getting the Post ID, the Post itself, the Custom Field values of the Post, and dynamically resizing the image from the Custom Field containing the image to be dynamically re-sized on-the-fly.
Re-size WordPress images on the fly vt_resize with multi-site support
I reformatted the source code so it’s more readable for my own eyes. If you want the original formatted source code, visit the link above.