How can I get the description of the image?
$album_id = get_the_id();
$photos = $wpdb->get_results(
"select * from wp_postmeta where post_id = '"
. $album_id
. "' AND meta_key = 'gallery_ph' order by meta_id desc"
);
This is the result of the SQL query:
Array ( [0] => stdClass Object ( [meta_id] => 887 [post_id] => 604 [meta_key] => gallery_ph [meta_value] => http://xxx/wp-content/uploads/2013/03/foto_03_copy200.jpg ) )
Image data is stored as if it were a post, or a CPT, so you can treat it like one.
Or, a little more complicated,…
get_the_ID
will return the ID of the current post so that will only work on an attachment page. I assume, since that is what you used, that is the context in which this is meant to work.Reference
https://codex.wordpress.org/Class_Reference/WP_Query