You’ll have to use different function for that.
wp_get_attachment_url
returns a full URI for an attachment file and it doesn’t know what type of attachment it is. It makes no sense to generate thumbnail for .zip od .txt files, so this function doesn’t allow you to get thumbnail url.
On the other hand, wp_get_attachment_image_url
knows that the file is an image, so you can tell it which size you want to get:
wp_get_attachment_image_url( int $attachment_id, string|array $size="thumbnail", bool $icon = false )
As you can see, second param is the size:
$size (string|array) (Optional) Image size to retrieve. Accepts any
valid image size, or an array of width and height values in pixels (in
that order).Default value: ‘thumbnail’
Related Posts:
- Is there a hook which fires after all thumbnails are generated?
- get_the_post_thumbnail_url with an unregistered size
- Cropped featured image replaces original image in gallery
- How do I delete all generated images from my server except those currently used in posts
- No srcset for hard-cropped thumbnails
- Cannot access the thumbnails of attachment images… Cannot find the reason
- Removing Title Tag from Thumbnails
- Regenerate missing _wp_attachment_metadata
- How to make programmatic image upload generate thumbnail and sizes?
- Disable wordpress image sizes generation
- WP 3.4 has missing photo data
- Display latest 12 images from media library
- Image Quality Thumbnail Compression in WordPress?
- Lazyload post thumbnails
- Retrieving an alt tag from a custom field
- Show full image thumbnail
- Image thumbnails not available post migration, but still accessible via direct URL – DB issue
- Upload media files to Amazon S3
- Dynamic tagged image galleries
- How to stop thumbnail generation from some images and different size thumbnail generate
- Update old Post image metadata to ‘thumbnail’ wp_attached_file
- How to stop wordpress always displaying full-res images
- Fixing image names for a site being restored
- force feed readers to pick atom version
- How to make thumbnails of uploaded animated gifs NOT animated
- Gallery with thumbnail carousel
- Is it possible to change image size used for preview thumnail in Add Media popup
- Generate images to be associated for tag and category?
- Display an icon with get_post_meta?
- Filter for post_thumbnail: link to small src and add data-attribute [duplicate]
- Dynamic image crop in WP 3.0+?
- Remove “%” from strings in serialized arrays in wp_postmeta
- How do I get a smaller size of an avatar image
- Why WordPress suddenly changed sizes of thumbnails?
- Stop WordPress compressing images? – Quality is terrible
- Rebuild thumbnails via WP Cli – how?
- Can we use featured image as third party website image URL
- Get an image from url, resize it, and save on a custom folder (not the media library)
- add_image_size not working
- Disable Media File Image Link On Mobile Devices
- Product Images Low Quality After Updating From WP 3.5 to 4 [closed]
- adding image to post thumbnail from another server
- Image not showing using a custom function and get_post_meta
- How to add thumbnails to posts and pages automatically in a uniformed fixed elegant way?
- Broken thumbnails (sometimes) with TimThumb
- Is it possible to save crop to a different size of the image when in image editor?
- how to change format jpg to webp?
- How to join Caption AND Description Meta Fields as one combined-caption in Image Block
- Apply manual image cropping not to thumbnail but medium_large size
- Images not showing after wordpres update 5.6
- how to regenerate webp et-pb-portfolio-image
- How to use default image as featured image by implement some code in function.php
- Auto Generate Thumbnail
- WordPress Multisite: Images moved to /sites/1?
- How to Display Image Caption but Not Alt Text
- unsharp thumbnails after uploading image
- ADD class to all my images (thumbail)
- When upload a PNG a noise appears in the thumbnails
- I cannot upload images to post or the media library in wordpress
- Why image Thumbnail url is not displaying with custom size?
- Blank image thumbnails in media library
- How to disable post-thumbnail from generation?
- New portfolio items appearing smaller on the grid
- WordPress can’t detect any thumbnails size?
- WooCommerce Variation Swatches and Photos – get attribute thumbnail
- get_post_meta returning broken path in image src
- Image thumbnail on single product issue | WooCommerce
- How Do I Auto Generate Thumbnail from First Embedded Image?
- Why doesn’t WordPress make thumbnails for videos?
- Adding Image Description below Images Inserted into Posts
- Create a custom attachment thumbnail for quick page load
- Why are my ‘medium’ images the wrong size
- Making a thumbnail if there exist a link with. jpg or .png extension in WordPress
- Imagem resolution responsive
- Add custom version to an image
- get_post_custom: get image URL instead of image ID
- WP is showing wrong image dimensions
- How to include featured image on blog post preview?
- Thumbnail size keeps resetting automatically
- Delete all thumbnails & regenerate them?
- Media Library shows default image instead of image preview
- Trying WP editor to load full size image (not ‘300×300’)
- Why are PDF thumbnails over-saturated?
- How can I get or the intermediate size of an image with wp_get_attachment_image_src without using post meta?
- show hide image script after 4 seconds [closed]
- Restricting users to view only media library items they have uploaded?
- How do I disable responsive images in WP 4.4?
- Filter to remove image dimension attributes?
- How to get a list of all the possible thumbnail sizes set within a theme
- How do I get the avatar URL instead of an HTML IMG tag when using get_avatar?
- Image Upload from URL
- Programmatically adding images to media library
- How do I delete all UNUSED images from my uploads directory?
- Set default image sizes in WordPress to hard crop
- Is it possible set a featured image with external image URL
- get attachment title based on attachment id
- How to disable WordPress from creating thumbnails?
- Stop wordpress from hardcoding img width and height attributes
- Handle issues with change of image scaling (rounding) in 4.1 (WP Ticket #18532)
- Programmatically get images by URL and save in uploads folder