How to extract specific image meta for all images?

Get all Images:

$all_images = get_posts( array(
     'post_type' => 'attachment'
    ,'numberposts' => -1
) );

foreach ( $all_images as $img )
    echo $img;

Some notes:

  • You can use extract to make your code shorter:

    extract( $image['image_meta'], EXTR_SKIP );
    echo $latitude;
    
  • Use Yoda Conditions.
  • When writing php on one line, you can also use shorthand php:

    // Instead of 
    if ($lng_ref == 'W') { $neg_lng = '-'; } else { $neg_lng = ''; }
    // Write Shorthand
    $neg_lng = 'W' === lng_ref ? '-' : '';
    
  • And stay to STRICT type checks:

    // Instead of just checking if the value is met,...
    if ( 'a' == $b )
    // ...also check if the value has the same type:
    if ( 'a' === $b )