The way to a thumbnail recording


Starting with version 2.9, WordPress has its own tool for creating thumbnail images, but not very convenient. This is the function the_post_thumbnail(), which allows you to add thumbnails through the standard bootloader and after clicking on the special. link, attach to the entry. The resulting images are scaled and cropped in a very strange way, and the resulting html code does not always match the needs.

The following piece of code takes only the path to the loaded thumbnail, which you can use at your own discretion by writing the desired markup. In the example, the thumbnail is displayed in a natural, downloaded size, without excess garbage:

<?php $thumb_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumb');
         $title = get_the_title($post->ID);

          if($thumb_url) {
             echo "<img src='$thumb_url[0]' alt='Миниатюра записи $title' class='alignleft' />";
          }
?>

Now we manage the image scaling – through the css class alignleft or through the attributes width or height.


Требуется подобная доработка? Напишите нам.


Name

Email


Website


Messagge