• Resolved joseoliveras

    (@joseoliveras)


    Hi, I’m trying to understand how the_post_thumbnail (array (100, 100)) works

    Does wordpress create an image of that size? Where is it stored?

    Or is it a temporary file that is generated every time the page is visited?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • No, WordPress does not generate a file. The only files WordPress generates for thumbnails for for named sizes. Either the built in ones (thumbnail, medium large etc.), or custom sizes added with add_image_size().

    When a width and height array is passed, as in you example, then the nearest size is used. Deep down inside the_post_thumbnail() the function image_get_intermediate_size() is used to determine the appropriate file to use. According to the docs for that function (emphasis mine):

    The $size parameter can be an array with the width and height respectively. If the size matches the ‘sizes’ metadata array for width and height, then it will be used. If there is no direct match, then the nearest image size larger than the specified size will be used.

    Looking at the source for the function, it appears that it will prioritise images of the same aspect ratio. So in your example, it will likely use the 150×150 thumbnail size.

    • This reply was modified 6 years, 12 months ago by Jacob Peattie.
    Thread Starter joseoliveras

    (@joseoliveras)

    I see, thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Understanding the_post_thumbnail (array (100, 100))’ is closed to new replies.