• Resolved yurenlimbu

    (@yurenlimbu)


    Hi,

    I’m using this code for gallery Lightbox

    $images = rwmb_meta( 'gallery', 'type=image&size=YOURSIZE' ); // Prior to 4.8.0
    if ( !empty( $images ) ) {
        foreach ( $images as $image ) {
            echo '<a href="', esc_url( $image['full_url'] ), '" title="', esc_attr( $image['title'] ), '" rel="lightbox"><img src="', esc_url( $image['url'] ), '" alt="', esc_attr( $image['alt'] ), '" /></a>';
        }
    }

    How can I use different image sizes for gallery.
    Example:
    echo '<a href="image size: 1280x720" rel="lightbox"><img src="image size: 480x320" alt="" /></a>';

    • This topic was modified 7 years, 1 month ago by yurenlimbu.
    • This topic was modified 7 years, 1 month ago by yurenlimbu.
    • This topic was modified 7 years, 1 month ago by yurenlimbu.
    • This topic was modified 7 years, 1 month ago by yurenlimbu.
Viewing 1 replies (of 1 total)
  • Plugin Author Anh Tran

    (@rilwis)

    The function rwmb_meta returns the attribute sizes for each image, which contains all the info about images.

    So you can change the code to:

    
    // Get URL for all image sizes
    $url = $image['url'];
    foreach ( $value['sizes'] as &$size ) {
        $size['url'] = dirname( $url ) . '/' . $size['file'];
    }
    
    // Echo. Rename "size_big" and "size_small" to your sizes.
    echo '<a href="', $image['sizes']['size_big']['url'], '" rel="lightbox"><img src="', $image['sizes']['size_small']['url'], '" alt="" /></a>';
Viewing 1 replies (of 1 total)
  • The topic ‘How to get different size images?’ is closed to new replies.