Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress Featured Image Dynamic resizing

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #34321
    vnvillar
    Participant

    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

    #87024
    TheDoc
    Member

    Do you mean when you resize your browser or when the image is uploaded?

    #87026
    vnvillar
    Participant

    I meant for when the image is uploaded :)

    #87034
    TheDoc
    Member

    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:

    #87072
    vnvillar
    Participant

    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

    #114014
    rfair404
    Member

    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.

    #127599
    thesk
    Participant

    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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.