• I am trying to find a way to assign thumbnail dimensions to its parent element dynamically so it works for all my posts.

    Example:
    <div><?php the_post_thumbnail(‘full’);?></div>

    All my thumbnails have different heights. Each value needs to be passed as a height parameter to the div holding the thumbnail. Please help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The container will grow to the thing inside it, so you don’t need to get the width and height of the image to assign to the div.

    Thread Starter sierrausa

    (@sierrausa)

    Yes, i need that value to space out the elements before the images are loaded because I am using masonry layout and the script collapses parent containers without heights before the images are loaded. imagesLoaded function is bugged with IE10 so I am trying to avoid using it. My parent containers MUST have heights. Please provide solution to the question I posted.

    This one I really don’t know off the top of my head.

    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
    $width = $image[1];
    $height = $image[2];
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Ho to pass thumbnail size to it's parent element’ is closed to new replies.