Tag Info

New answers tagged

1

You are not providing a correct attachement ID. Replace: $image_alt = get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true); With: $image_alt = get_post_meta( $image->id, '_wp_attachment_image_alt', true); Note: I assume that $image->id is correct because you use it later in your code and you get the expected result. Unfortunatley ...


0

The way I would do this would be to inline the background: url(...) property. <?php if ( has_post_thumbnail() ) : $hero = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'hero', '' ); $tablet = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID), 'tablet', '' ); $phablet = wp_get_attachment_image_src( ...



Top 50 recent answers are included