- This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hi guys,
I’m currently working on a wordpress theme and stumbled on this problem. Do you guys have an idea on how to dynamically resize the image that I’ve uploaded using the WordPress Featured Image function?
Hope you guys could help? Thanks in advance :)
Best,
Val
Do you mean when you resize your browser or when the image is uploaded?
I meant for when the image is uploaded :)
Much easier to explain then!
You’ll want to add this to your functions.php file (you can find that in your theme’s folder):
// add post-thumbnail functionality
if (function_exists('add_theme_support')) { add_theme_support('post-thumbnails'); }
set_post_thumbnail_size( 100, 100, true ); // Normal post thumbnails
add_image_size( 'custom-1', 125, 125, true ); // Custom size that will crop the image to fit the proportion
add_image_size( 'custom-2', 255, 236, false ); // Default is false, "soft proportional crop"
If you don’t yet have a functions.php file in your theme’s folder, you can simply create one and add the code above. If you already have one and it’s using featured images already, then chances are you’ll just have to add the add_image_size stuff.
To call a featured image with a specific size in your templates, you can use this:
Wow, cool! This is really a big help. Thank you so much TheDoc. Really appreciate it. :)
More power to Chris and CSS-Tricks site! :D
Val
So what about when the browser is resized? I’m trying to figure out away to serve up the smaller size image for mobile devices and the larger size on desktop sizes. Ideas? Oh complicate it by stating that I also want to be able to use a caching plugin like w3Total Cache or some other cache.
Sir You Have Missed –> ‘ <-- after the "custom-1" in so i hope you will fix it soon and i dont want other to suffer syntax problem as i have faced.