R
R
Rokis2018-03-02 21:54:38
Images
Rokis, 2018-03-02 21:54:38

How to dynamically display the image from which the Wordpress thumbnail is generated?

Hello.
When adding an image to the library, it is cropped to a certain size using a plugin (tinypng) and the original is overwritten. From this picture, a miniature with a smaller size is obtained.
Question: how to display the original picture ( from which the thumbnail is obtained ) dynamically ( not by ID )? Or how to get the ID of the desired image for further work automatically?
The picture must be displayed on the post page and without using the editor.
I think you should use <?php echo wp_get_attachment_image( ); ?>, but only the thumbnail is captured here.
To make it even clearer: the effect should be exactly the same as if I inserted a picture from the media library in the post editor.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yanchevsky, 2018-03-02
@Rokis

Hello.
In the case of the wp_get_attachment_image function, you can specify the size as the second parameter. The original is full.
If this is a post or page image, then the the_post_thubmnail or the_post_thumbnail_url functions can be used.

<?php the_post_thumbnail('full'); ?>

<img src="<?php the_post_thumbnail_url('full'); ?>" alt="">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question