• Resolved kevgibs

    (@kevgibs)


    I’m using Plupload to upload images used in a custom template, the images are pulled into a flexslider gallery.

    Problem is, I’m uploading images at 1000x600px and they’re coming through at that size on the frontend before being resized.

    Is there a way to define a set of image sizes, so images are resized on upload, in the way WordPress does anyway? That way I can then tell the template to use images sized correctly for the frontend, reducing the page load.

    https://ww.wp.xz.cn/plugins/meta-box/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Anh Tran

    (@rilwis)

    Hi,

    All image upload fields use WordPress image sizes, which are registered by theme or plugins.

    When you display images in the frontend, don’t get the “full” size. Instead, you just need to specify a param size=$size_name (where $size_name is an image size which is registered before with add_image_size function) and you will get a smaller version, like this:

    $images = rwmb_meta( 'gallery', 'type=image&size=YOURSIZE' );
    foreach ( $images as $image )
    {
        echo "<a href='{$image['full_url']}' title='{$image['title']}' rel='thickbox'><img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$image['alt']}' /></a>";
    }

    Best regards

    Thread Starter kevgibs

    (@kevgibs)

    Brilliant, thank you, I really appreciate that.

    When I add:

    add_image_size( 'flexslider-thumb', 167, 119 );
    add_image_size( 'flexslider-main', 757, 454 );

    To functions.php, then use those size names in the flexslider code like this:

    $images = rwmb_meta( 'swso_prodImage', 'type=image&size=flexslider-main');
    foreach ( $images as $image )
    {
       echo "<li><a href='{$image['full_url']}' title='{$image['title']}' rel='thickbox''><img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$image['alt']}' /></a></li>";
    }

    Then re-upload the images, it all works fine.

    I do have another question though. The link to the full size image adds “/undefined” to the current page URL rather than actually linking to the full size image. Any ideas what could be causing this?

    Plugin Author Anh Tran

    (@rilwis)

    That sounds strange to me. I haven’t seen that problem. The function that gets full URL only uses WP function wp_get_attachment_url, which shouldn’t return any “undefined” string.

    Maybe you should try regenerate thumbnails? Or do you have any plugins/settings related to the attachment?

    Thread Starter kevgibs

    (@kevgibs)

    It could well be related to flexslider. I’ll look at that, thanks again.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Define image sizes with Plupload’ is closed to new replies.