function wp_get_attachment( $attachment_id ) {
$attachment = get_post( $attachment_id );
return array(
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'href' => get_permalink( $attachment->ID ),
'src' => $attachment->guid,
'title' => $attachment->post_title
);
}
As sporkme explains later in the thread, this is dumped into your functions.php and can then be called with $attachment_meta = wp_get_attachment(your_attachment_id);
.
Related Posts:
- How to have different captions for same image, for galleries?
- Featured image shortcode
- How to wrap WordPress image captions inside H2, H3 tags?
- Is there a way to define a default caption to all uploaded images
- How to add a link in a image’s caption?
- Alter media caption/description conflict in WordPress?
- How to display a shortcode caption somewhere other than the_content
- Caption in Page adding unwanted 10px to width
- Adjust image caption within visal editor
- Drag images with caption in WP editor
- Different captions for the same image in multiple galleries. Edit Image in Gallery locally
- Include captions
- HTML tags in WordPress image caption
- Add attribute to caption shortcode from custom attachment field
- Removing height and width from images with a caption
- Include caption underneath post images
- Turn off image captions in gallery view?
- Move Image Captions Inside Link ( tag) if Added
- How to add custom classes to figure element only if image has caption?
- Replace image caption with its title and description
- Omit image captions from get_the_content()
- Random home page background images with caption text
- How to edit caption for images and exclude it from excerption query?
- Place image caption outside of figure tag (Gutenburg Image Markup)
- How to join Caption AND Description Meta Fields as one combined-caption in Image Block
- how automatically show the image title before the image caption/description in a wordpress gallery?
- How to Display Image Caption but Not Alt Text
- How to auto add image caption from image alt?
- Is there a way to create referable automatic numbering in image captions?
- Displaying “alt” attribute text as captions?
- page displaying media caption shortcodes
- How to add a credit line to a photo caption
- Wrap a post image with a div if it doesn’t have a caption
- get attachment title based on attachment id
- How to extend the gallery block in Gutenberg?
- Allow contributor role to upload images and not edit already published articles
- Why is wp_get_attachment_image_src not working with my custom size (add_image_size)
- How to give image source in wordpress page editor?
- Making WordPress Gallery (.gallery-item) Responsive?
- Width 100%: Aspect ratio of image
- Upload images using FTP and show them in media
- add_image_size() cropped only if width of the image matches or is higher
- How to Make WordPress Default gallery responsive on mobile?
- Why does wordpress generate more thumbnails than the 3 standard sizes?
- Pulling Post Image Attachments in WordPress 3.9
- including image assets in widget
- Link Featured Thumb to Attachment Page, If Possible
- Is there a shortcut to change bulk BMP images to JPG images in a site?
- WordPress Post featured image URL in the header
- Add instructions to featured image
- How do I get more image editing options in the admin?
- HTTP Error when uploading files above 7mb unless using GD Image Editor
- Image resize using url parmater
- How to display / include a specific jpg on a page
- Grab remote images and update links in existing posts
- Store Snapshot created via wordpress to use with lightbox
- Get image URL after image created from canvas and sent to WP uploads with AJAX
- How can I use cached images in an AJAX response?
- Can’t get images to align with Gutenberg editor
- Retrieve image from content, assign it as a featured, and then remove it from the content
- Custom Loop, Match Category with Page: How to display post featured image?
- Modifying the HTML Output of Inserted Images
- Google verification challenge with file location
- How to check for images before echo
- Remove height attribute from wp_get_attachment
- How do I retrieve an image’s width and height using Advanced Custom Fields?
- wp get attachment image always gives me thumbnail
- Two “the_excerpt” questions
- Images are not showing after moving WordPress installation from server to localhost?
- Images are not showing up in “Uploaded to this post”
- Cache DB queries result
- Remove “%” from strings in serialized arrays in wp_postmeta
- Images not found after migrating WordPress website
- Adding srcset to an image in ajax
- Error uploading images in wordpress
- Disable Media File Image Link On Mobile Devices
- Set two default featured images
- Automatically generate missing images
- Apply nextgen-gallery lightbox effect [closed]
- VT-resize (great alternative to timthumb) : Errors cropping (litespeed, centos 6.3)
- Page speed error: “serve scaled images”
- Image Captions Have a 10px Extra Margin, And It’s Not CSS? [duplicate]
- x2 images for retina?
- Load url image full size in thumbnail, medium, large size
- WordPress can’t detect any thumbnails size?
- Remove image border in twentyeleven theme [closed]
- 403 Forbidden when accessing image in wordpress
- For what does WP generate Thumbnails?
- Images are not shown
- Remove the height limit on wordpress 3.4.2
- Image media upload problem in page editing modus?
- Is there a good way to use CMS images with CSS
- Upload image from other server without resize?
- where is images/image.jpg?
- Using the on-board image editor for featured images: edits are not being used
- change with CSS the color of an svg background image set with “background-image: url()”
- What type to upload image within theme options?
- Media Library shows default image instead of image preview
- Uploading media to wordpress API with C# HttpClient
- How to add image alt attribute to the thumbnail code