WordPress.org

Ready to get started?Download WordPress

Forums

Image Metadata Cruncher
Can I access the data using WP functions? (2 posts)

  1. theMikeD
    Member
    Posted 1 year ago #

    Once this plugin has done it's thing, can I then access the stored metadata in normal WP ways? For example:

    $meta = wp_get_attachment_metadata($image->ID);
    $tag = $meta['image_meta']['my_custom_image_meta_tag'];

    Will that work?

    http://wordpress.org/extend/plugins/image-metadata-cruncher/

  2. peterhudec
    Member
    Plugin Author

    Posted 1 year ago #

    Yes,

    Attachments (uploaded images) are represented in the DB as posts. You can get any post with $post_object = get_post( $post_id, $output ). But you need the attachment ID. I'm not sure but I think that you can get the post attachments with get_posts( $args ). You must specify 'post_parent' and 'post_type' => 'attachment' in the $config.

    When you have the $post_object, the metadata extracted by IMC plugin are accessible in:

    • $post_object->post_title The title field in settings.
    • $post_object->post_excerpt Caption field.
    • $post_object->post_content Description field.

    The Alt field as well as all the custom meta you specified in IMC settings is stored in the post meta and you can get it with get_post_meta($post_id, $key, $single).

    Here are some usefull links:
    http://codex.wordpress.org/Function_Reference/get_post_meta
    http://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata
    http://codex.wordpress.org/Template_Tags/get_posts

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.