Y
Y
yakupov1122018-07-05 16:33:55
WordPress
yakupov112, 2018-07-05 16:33:55

How to create thumbnails with custom sizes for a specific image?

For example, I want to cut thumbnails of 300x300 for some images, 150x150 for others, and not for all images, thumbnails of 300x300 and 150x150 are cut. Using Advanced Custom Fields to upload images

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
ljutaev, 2018-07-05
@ljutaev

hello)
in the functions.php file you write:

add_image_size( 'thumb_1', 150, 150,  true );
add_image_size( 'thumb_2', 300, 300,  true );

<?php
// Подразумевается, что у вас в библиотеке есть картинка с ID 1 и 2...
// для вывода в цыкле нужно сначала получить ID
echo wp_get_attachment_image(1, 'thumb_1' );
echo wp_get_attachment_image(1, 'thumb_2' );
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question