Introduction to WordPress Post Thumbnails
Publication thumbnails, also known as featured imagesimages are a crucial element in WordPress. These images not only enhance the aesthetics of your site, but also attract the attention of visitors. Getting the URL of a post thumbnail can be useful for tasks such as sharing on social networks or embedding on other websites. In this article, we will explore how you can easily obtain this URL.
Where are the images stored in WordPress?
Images, including post thumbnails, are stored in the WordPress media library. Each time you upload an image, WordPress generates various sizes of the image, including the thumbnail, which is usually smaller and optimized for use in listings and previews.
Access to the Media Library
To access the media library, follow these steps:
- Log in to your WordPress administration panel.
- Go to "Media" in the side menu.
- Select "Library".
Here you will find all the images you have uploaded. By clicking on an image, you will be able to see details about it, including its URL.
How to Obtain the URL of the Publication Thumbnail
There are several ways to get the URL of your post's thumbnail. Below are the most common methods:
Manual Method Through the Media Library
This is the most direct and simple method.
- In the media library, locate the image you want.
- Click on the image to open the details panel.
- On the right side, you will see a section called "File URL".
Copy the URL that appears there. This is the direct address to the full image. However, if you want the thumbnail, you need to make a small adjustment to the URL.
Using Code to Obtain the URL of the Thumbnail
If you prefer to do it through code, WordPress offers functions that allow you to get the thumbnail URL programmatically. Here's an example of how to do it in a template file:
This code uses the function get_the_post_thumbnail_url() to get the URL of the thumbnail. You can change the second parameter to get different image sizes.
What Miniature Sizes Are Available?
WordPress generates several image sizes by default. Here is a table with the most common sizes:
| Size | Dimensions (in pixels) |
|---|---|
| Miniature | 150 x 150 |
| Medium | 300 x 300 |
| Grande | 1024 x 1024 |
| Complete | Original |
These sizes can be customized in the "Settings" section in WordPress, allowing you to adapt the images to the needs of your site.
Final Considerations on the Use of Miniatures
When using thumbnails, it is important to consider the quality and size of the images. An image that is too heavy can affect the loading speed of your site, which in turn can impact user experience and SEO.
Image Optimization
To optimize your images, you can use plugins such as Smush o Imagifywhich help you compress images without losing quality. This not only improves the loading speed, but also optimizes the space on your server.
Also, be sure to use appropriate image formats. Formats such as WebP are lighter and offer superior quality compared to JPEG or PNG, which can be beneficial for your website.
