From 7132bc4b43769e2838e238d2c8ed132f0e5dcab7 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Thu, 14 May 2020 17:16:29 +0200 Subject: [PATCH] Dirty update to support displaying images without GPX track --- wp-gpx-maps.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/wp-gpx-maps.php b/wp-gpx-maps.php index 04aa3cc..64035ca 100644 --- a/wp-gpx-maps.php +++ b/wp-gpx-maps.php @@ -342,6 +342,8 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) { $colors_map = "\"" . implode( "\",\"", ( explode( " ", $color_map ) ) ) . "\""; $gpxurl = $gpx; + + if ( ! $gpx == null ) { /* Add file modification time to cache filename to catch new uploads with same file name */ $mtime = wp_gpx_maps_sitePath() . str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, trim( $gpx ) ); @@ -433,9 +435,9 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) { $gpx = str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, $gpx ); $gpx = $sitePath . $gpx; } - if ( $gpx == '' ) { - return "No gpx found"; - } + //if ( $gpx == '' ) { + // return "No gpx found"; + //} $points = wpgpxmaps_getPoints( $gpx, $pointsoffset, $donotreducegpx, $distanceType ); @@ -640,6 +642,14 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) { $points_graph_grade = ''; } + } else { + // $gpx == null (no GPX track to display, only images...) + $points_x_time = array(); + $points_x_lat = array(); + $points_x_lon = array(); + $waypoints = '[]'; + $points_maps = ''; + } $ngimgs_data = ''; if ( $ngGalleries != '' || $ngImages != '' ) { @@ -662,7 +672,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) { } } - if ( ! ( $skipcache == true ) ) { + if ( ! ( $skipcache == true ) && ! ( $gpx == null ) ) { @file_put_contents( $gpxcache, serialize( array( 'points_maps' => $points_maps, @@ -694,7 +704,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) { @chmod( $gpxcache, 0755 ); } - $hideGraph = ( $gh == '0' || $gh == '0px' ); + $hideGraph = ( $gh == '0' || $gh == '0px' || $gpx == null ); global $post; $r = $post->ID . '_' . rand( 1,5000000 );