0

I want Get wordpress media library image class. I have attachment id and I tired this but won't able to get it.

print_r(wp_get_attachment_image_src( $attachment_id, $size, $icon, $attr ));

How can I get it ?enter image description here

1

If this is a regular custom field, use get_post_meta():

$classes = get_post_meta( $attachment_id, 'name_of_the_field', TRUE );

attachment is just another post type, regarding to meta data, it works like regular posts or pages.

  • Here is the field <input type="text" class="text" id="attachments-28-classes" name="attachments[28][classes]" value=""> – Ajay Patel Aug 31 '13 at 8:03
  • That’s just the name in the HTML form, it doesn’t tell you what name is used in the database. This is why I asked for that in my comment. – fuxia Aug 31 '13 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.