{ Dev Farm }

Web & Windows Development

Patch for wp-gpx-maps-utils.php

Home Forum Wp Gpx Maps Support Patch for wp-gpx-maps-utils.php

  • Il topic è vuoto.
Stai visualizzando 1 post (di 1 totali)
  • Autore
    Post
  • #98859 Rispondi
    Rob
    Ospite

    I posted yesterday but it wasn’t clear if the form accepted my text since I received an error afterwards. I have been working to get attachments=”true” to work with my photos that are not in an NG Gallery. I made a few code tweaks to the wp-gpx-maps-utils.php file to get it to work. Specifically, I found if the URL to the file is used, the GPS metadata doesn’t get returned by exif_read_data. I used the attachments feature to get the path to the file, which then will return the GPS metadata and allow lon/lat to be added.

    I also had to debug some quirks with my data related to timing differences between my GPS and pics. I found using the exif DateTimeOriginal and an offset fixed my issues and tweaked the code to use those values.The old code reference the $p variable which looks to be a copy/paste from the nggallery code.

    Now I have the pics linked but the URL is blank on the rendered map. You can see this at https://www.robbosch.com/backpacking-big-bend-outer-mountain-loop. Any suggestion on why the URL to the photo is blank? Once that is fixed, I think it all works.

    Pasted my current function below which is working except for the display.

    Sorry if this is a duplicate from before.

    Thanks,
    Rob

    [code]
    — wp-gpx-maps-utils.php.bak 2022-02-02 05:56:52.367435802 -0800
    +++ wp-gpx-maps-utils.php 2022-02-02 06:00:16.362512263 -0800
    @@ -25,6 +25,7 @@
    $img_src = wp_get_attachment_image_src( $attachment_id, ‘full’ );^M
    $img_thmb = wp_get_attachment_image_src( $attachment_id, ‘thumbnail’ );^M
    $img_metadata = wp_get_attachment_metadata( $attachment_id );^M
    + $image_file = get_attached_file( $attachment_id, $unfiltered );^M
    ^M
    $item = array();^M
    $item[‘data’] = wp_get_attachment_link( $attachment_id, array( 105, 105 ) );^M
    @@ -32,7 +33,7 @@
    if ( is_callable( ‘exif_read_data’ ) ) {^M
    ^M
    try {^M
    – $exif = @exif_read_data( $img_src[0] );^M
    + $exif = @exif_read_data( $image_file );^M
    } catch (Exception $e) {^M
    $exif = false;^M
    }^M
    @@ -42,8 +43,8 @@
    $item[‘lat’] = getExifGps( $exif[‘GPSLatitude’], $exif[‘GPSLatitudeRef’] );^M
    if ( ( $item[‘lat’] != 0 ) || ( $item[‘lon’] != 0 ) ) {^M
    $result[] = $item;^M
    – } elseif ( isset( $p->imagedate ) ) {^M
    – $_dt = strtotime( $p->imagedate ) + $dtoffset;^M
    + } elseif ( isset( $exif[‘DateTimeOriginal’] ) ) {^M
    + $_dt = strtotime( $exif[‘DateTimeOriginal’] ) + $dtoffset;^M
    $_item = findItemCoordinate( $_dt, $dt, $lat, $lon );^M
    if ( $_item != null ) {^M
    $item[‘lat’] = $_item[‘lat’];^M
    [\code]

Stai visualizzando 1 post (di 1 totali)
Rispondi a: Patch for wp-gpx-maps-utils.php

You can use BBCodes to format your content.
Your account can't use Advanced BBCodes, they will be stripped before saving.

Le tue informazioni:




Non è possibile lasciare nuovi commenti.