M
M
maksimkoh2016-08-17 20:51:01
PHP
maksimkoh, 2016-08-17 20:51:01

How to make an image responsive when displaying an image using php?

Good evening! I am doing the output of news in wp and bootstrap and I want the previews to be adaptive. Here is the code:

<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
  <?php the_post_thumbnail();>
</a>

Specifying img tags in src="<?php the_post_thumbnail();>" does nothing. How should one act in such situations?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Milok Murlyka, 2016-08-17
@maksimkoh

If this is WordPress + bootstrap, you can do this:

<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
  <?php the_post_thumbnail(null, array("class" => "img-responsive")) ;?>
</a>

Function documentation the_post_thumbnail, the second parameter is used to set attributes (including classes)

A
Alexander Aksentiev, 2016-08-17
@Sanasol

And here php?
Write CSS for different sizes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question