4
I need to add a width="100%"
and the class="img-responsive"
.
How do I add in img if I call it in index this way?
<?php the_post_thumbnail(); ?>
4
I need to add a width="100%"
and the class="img-responsive"
.
How do I add in img if I call it in index this way?
<?php the_post_thumbnail(); ?>
4
Do it like this:
<?php
$thumb_id = get_post_thumbnail_id();
$thumb_url = wp_get_attachment_image_src($thumb_id,'thumbnail-size', true);
echo "<img src='".$thumb_url[0]."' width='100%' class='img-responsive' />";
?>
get_post_thumbnail_id
takes the id of the Thumb.
wp_get_attachment_image_src
takes the image url, passing the Thumb id as parameter.
Very good, helped me too!
Opa worked, thanks man! and will help in future projects!
Browser other questions tagged php wordpress
You are not signed in. Login or sign up in order to post.
Try this way <?php the_post_thumbnail( 'thumbnail', array( 'class' => 'alignleft' ) ); ?>
– Matheus Ilário