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
- Remove images (files) that were generated when using add_image_size()
- Displaying images from external RSS feeds?
- Preview Image Path in Admin Section
- Featured Images on Front Page
- How to get source of custom meta image?
- Ability to edit image via WYSIWYG
- Featured image (responsive) above content is too small after update to WordPress 4.4
- WP keeps looking up post thumbnail on https even though wp-config says http
- How to post a mosaic of an image gallery instead of the entire gallery inside a post’ [closed]
- using media_sideload_image with a file from theme directory
- WordPress shows my picture in admin bar
- Using jQuery to automatically add class only to gif images in WordPress database [closed]
- Removing Images from a WordPress Post
- Random Image Script Working but Want to Avoid Duplicates
- HTML Img with data:image src gets sanitized in admin?
- Can’t find image to remove
- Jetpack Lazy load images fade in
- Display images in template file
- Custom filename when pasting an image from clipboard