{ Dev Farm }

Web & Windows Development

Upload and Download of gpx files

Home Forum Wp Gpx Maps Support Upload and Download of gpx files

  • Questo topic ha 2 risposte, 1 partecipante ed è stato aggiornato l'ultima volta 7 anni, 11 mesi fa da konus.
Stai visualizzando 3 post - dal 1 a 3 (di 3 totali)
  • Autore
    Post
  • #25540 Rispondi
    konus
    Ospite

    Hello,

    On my website I offer the download link to the gpx file to my readers.
    Unfortunately, my browser (firefox) tried to open the gpx-file as xml without styling.

    I found out, that adding the attribute “download” to the link does the trick and forces the browser to download the file instead of trying to display it. See http://www.w3schools.com/tags/att_a_download.asp for details.

    So I went to wp-gpx.maps.php in the plugin directory and edited line 731 from
    $output.=”“.__(“Download”, “wp-gpx-maps”).”“;
    to
    $output.=”“.__(“Download”, “wp-gpx-maps”).”“;

    An other problem is to upload gpx-files to wordpress via media-uploader. I needed to add the following lines to my functions.php to allow uploads of gpx-files:

    add_filter(‘upload_mimes’, ‘custom_upload_mimes’);
    function custom_upload_mimes ( $existing_mimes=array() ) {
    $existing_mimes[‘gpx’] = ‘application/gpx+xml’;
    return $existing_mimes;
    }

    Maybe both solutions could be part of the next version of this wonderful plugin? Thanks for your work!
    Greetings Konrad :good:

    #25541 Rispondi
    konus
    Ospite

    Sorry, I try to repair the formatting a bit:

    Hello,

    On my website I offer the download link to the gpx file to my readers.
    Unfortunately, my browser (firefox) tried to open the gpx-file as xml without styling.

    I found out, that adding the attribute “download” to the link does the trick and forces the browser to download the file instead of trying to display it. See http://www.w3schools.com/tags/att_a_download.asp for details.

    So I went to wp-gpx.maps.php in the plugin directory and edited line 731 from
    $output.="<a href='$gpxurl' target='_new' >".__("Download", "wp-gpx-maps")."</a>";
    to
    $output.="<a href='$gpxurl' target='_new' download>".__("Download", "wp-gpx-maps")."</a>";

    An other problem is to upload gpx-files to wordpress via media-uploader. I needed to add the following lines to my functions.php to allow uploads of gpx-files:

    add_filter('upload_mimes', 'custom_upload_mimes');
    function custom_upload_mimes ( $existing_mimes=array() ) {
    	$existing_mimes['gpx'] = 'application/gpx+xml'; 
    	return $existing_mimes;
    }

    Maybe both solutions could be part of the next version of this wonderful plugin? Thanks for your work!
    Greetings Konrad :good:

    #25542 Rispondi
    konus
    Ospite

    I just found the github page and found out, that the download attribute was added yesterday . What a coincidence!

    How difficult would it be to add the mime filter to the code?

Stai visualizzando 3 post - dal 1 a 3 (di 3 totali)
Rispondi a: Upload and Download of gpx files

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.