From de3b4f2593c07f632d225564c2211b10b4171ac3 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Sat, 9 May 2020 17:46:21 +0200 Subject: [PATCH] Checking array indexes before using them (#1) --- wp-gpx-maps_utils_nggallery.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-gpx-maps_utils_nggallery.php b/wp-gpx-maps_utils_nggallery.php index b4ad7e6..5b88078 100644 --- a/wp-gpx-maps_utils_nggallery.php +++ b/wp-gpx-maps_utils_nggallery.php @@ -39,8 +39,10 @@ function getNGGalleryImages( $ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset if ( is_callable( 'exif_read_data' ) ) { $exif = @exif_read_data( $p->imagePath ); if ( $exif !== false ) { - $item['lon'] = getExifGps( $exif['GPSLongitude'], $exif['GPSLongitudeRef'] ); - $item['lat'] = getExifGps( $exif['GPSLatitude'], $exif['GPSLatitudeRef'] ); + $item['lon'] = (array_key_exists('GPSLongiture', $exif) and array_key_exists('GPSLongitudeRef', $exif)) ? + getExifGps( $exif['GPSLongitude'], $exif['GPSLongitudeRef'] ) : 0; + $item['lat'] = (array_key_exists('GPSLatitude', $exif) and array_key_exists('GPSLatitudeRef', $exif)) ? + getExifGps( $exif['GPSLatitude'], $exif['GPSLatitudeRef'] ) : 0; if ( ( $item['lat'] != 0 ) || ( $item['lon'] != 0 ) ) { $result[] = $item; } elseif ( isset( $p->imagedate ) ) {