WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#11896 closed defect (bug) (invalid)

wp_get_attachment_metadata not grabbing some metadata

Reported by: danielpataki Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9.1
Component: General Keywords: wp_get_attachment_metadata
Focuses: Cc:

Description

Hello!

I have been using and developing with Wordpress for years, but this is my first bug report, so if I am wrong, or do not use proper etiquette, please let me know!

I created a function to retrieve some of the uploaded images, and I wanted to use wp_get_attachment_metadata to grab some of the attachements metadata.

When I uploaded the images I added titles and descriptions and captions and whatnot, but I can't seem to retrieve them with this function.

If I try the following:
$meta = wp_get_attachment_metadata( $att->ID, true);
print_r($meta);

I would expect the caption to be contained in
$metaimage_meta?caption?

I may be wrong because this array has exif data as well, so this variable may hold caption data from exif data, and not from wp_posts->post_excerpt?

In any case, this function does not return any of the image data I entered, while based on the name of the function I'm sure it could be expected.

Please see the attached images for the entered image metadata and the printed array on the page

I hope this really is a bug, if not, please excuse me for wasting your time.

Attachments (2)

image_upload_screen.gif (32.4 KB) - added by danielpataki 4 years ago.
Added imahe metadata
printed_array.gif (6.5 KB) - added by danielpataki 4 years ago.
Printed array values for the same attachement

Download all attachments as: .zip

Change History (3)

danielpataki4 years ago

Added imahe metadata

danielpataki4 years ago

Printed array values for the same attachement

comment:1 dd324 years ago

  • Milestone Unassigned deleted
  • Resolution set to invalid
  • Status changed from new to closed

Yes, The metadata function returns the image Metadata.

The Metadata is not the Caption/Description/Title data which has been entered, Think of the metadata as the custom fields of attachments, Its all the data that needs to be stored about attachments under the hood.

You can access the data you expect through the normal template tags, such as get_the_title(), the_content() and the_Excerpt() i'm pretty sure.

To check which is which, you can dump out the post object for the attachment:

$attachment = get_post( $attachment_id );
var_dump($attachment);

Then use the normal post template tags to retrieve the contents from the fields you want from there.

If you need some help on how to use those functions, i'd suggest the wp-hackers mailing list or the support forums as that is not what trac is for.

Note: See TracTickets for help on using tickets.