Piwigo / piwigo-openstreetmap

OpenStreetMap integration for Piwigo
http://piwigo.org/ext/extension_view.php?eid=701
GNU General Public License v3.0
35 stars 35 forks source link

Possible to change shown picture for gpx files? #71

Open ThomasDaheim opened 8 years ago

ThomasDaheim commented 8 years ago

Hi,

in case of gpx files the thumb/picture is always shown as a question mark. Is there any way to modify that and replace by some placeholder image?

Thanks, Thomas

xbgmsharp commented 8 years ago

Could you please provide a screenshot? Question mark images are not from the plugin.

ThomasDaheim commented 8 years ago

First screenshot: Questionmarks when viewing Gallery with gpx and kml file: clipboard01 Second screenshot: kml file image view: clipboard02 HTH, Thomas

xbgmsharp commented 8 years ago

In the gallery, for GPX file you are suppose to have this icon. https://github.com/xbgmsharp/piwigo-openstreetmap/blob/master/mimetypes/gpx.png

Could you test using the latest github version.

ThomasDaheim commented 8 years ago

Tried using the latest version. The gpx.png is present but still doesn't get shown.

xbgmsharp commented 8 years ago

The function call is osm_get_mimetype_icon. Try to debug $element_info and $location. https://github.com/xbgmsharp/piwigo-openstreetmap/blob/master/gpx.inc.php#L90

Maybe you change to support KML, break the mimetype.

screen shot 2015-10-23 at 10 53 01 pm
ThomasDaheim commented 8 years ago

I did a rollback of my changes to gpx.inc.php but still no icon :-(

As for debugging php: Might take a day or two until I learn how to do that...

ThomasDaheim commented 8 years ago

I finally managed to have look into that. I added some print_r's into function osm_get_mimetype_icon($location, $element_info) and this is the output when looking at a gpx:

element_info: gpx - location: plugins/piwigo-openstreetmap/mimetypes/gpx.png

Looks pretty reasonable to me. Now the question is why the image isn't shown. Maybe I would need to enable ".png" somewhere as valid image extension?

xbgmsharp commented 8 years ago

The result is correct. No need to enable ".png" as valid image extension. On your gallery display the image HTML code using the inspector from the web development tools.

screen shot 2015-10-27 at 6 42 54 pm

Also do you have any custom config from your webserver or PWG?

ThomasDaheim commented 8 years ago

My config.inc.php:

<?php

/* The file does not exist until some information is entered 
below. Once information is entered and saved, the file will be created. */

/* set time zone explicitly to avoid php warning */
date_default_timezone_set('Europe/Berlin');

/* no caption under thumbs, please! */
$conf['show_thumbnail_caption'] = false;

/* don't show filename on picture page */
$conf['show_picture_name_on_title'] = false;

/* show exif info */
$conf['show_exif_fields'] = array(
  'Make',
  'Model',
  'latitude',
  'longitude',
  'FNumber',
  'ExposureBiasValue',
  'ExposureTime',
  'ISOSpeedRatings',
  'FocalLength',
  'ExposureMode',
  'MeteringMode',
  'ExposureProgram',
  );

/* load all file types - not only images
needed for gpx, see https://github.com/xbgmsharp/piwigo-openstreetmap/issues/50 */
$conf['upload_form_all_types'] = true;

$conf['use_exif'] = true;

/* allow spaces in file names */
$conf['sync_chars_regex'] = '/^[a-zA-Z0-9-_. ]+$/';

?>

My main.inc.php:

<?php
/*
Plugin Name: Personal Plugin
Version: 1.0
Description: Personal Plugin
Plugin URI: http://piwigo.org
Author: Thomas Feuster
Author URI:
*/

add_event_handler('loc_end_page_tail', 'perso_remove_contact_link_footer');
function perso_remove_contact_link_footer()
{
  global $template;

  $template->assign('CONTACT_MAIL', null); // core contact link
  $template->assign('ContactFormLink', null); // ContactForm plugin link
}

/* hide standard about */
if (script_basename() == 'about')
{
  add_event_handler('loc_end_page_header', 'nopiwigoabout');
}

function nopiwigoabout()
{

  global $template;
  $template->clear_assign('ABOUT_MESSAGE');
}

?>
ThomasDaheim commented 8 years ago

In my gallery the HTML code is different: clipboard01 Somehow in the end it is "unknown.png" that gets shown?

xbgmsharp commented 8 years ago

Are you on windows? The OSM call set a mine-type otherwise the default unknown is used. https://github.com/xbgmsharp/piwigo-openstreetmap/blob/master/gpx.inc.php#L90 In include/derivative.inc.php on line 74 You can try to add a debug print for PHPWG_ROOT_PATH.$this->rel_path before the IF. add another debug for the return value of getimagesize, http://php.net/manual/en/function.getimagesize.php

You also make sure the _data/ to be writable by your webserver.

ThomasDaheim commented 8 years ago

I have added print_r's and " - " as separator for readability.

- ./plugins/piwigo-videojs/mimetypes/gpx.png - Array ( [0] => 48 [1] => 48 [2] => 3 [3] => width="48" height="48" [bits] => 16 [mime] => image/png ) - 

Path is to piwigo-videojs? AND there is no file gpx.png! For testing I have copied gpx.png to the piwigo-videojs folder and now it shows up correctly...

xbgmsharp commented 8 years ago

That is weird, the path should not be piwigo-videojs It does return the path and the size alone with the mine-type. Add print ($size=@getimagesize(PHPWG_ROOT_PATH.$this->rel_path))

ThomasDaheim commented 8 years ago

I noticed that I had placed the print_r for size in the IF... Here is the corrected output with empty output for $size=@getimagesize(PHPWG_ROOT_PATH.$this->rel_path):

- ./plugins/piwigo-videojs/mimetypes/kml.png - -

As said above - since the search path contains piwigo-videojs the gpx.png from your plugin won't be found. As crosscheck: manually copying it into the piwigo-videojs folder makes it appear correctly.

xbgmsharp commented 8 years ago

True, the path is wrong, eg: piwigo-videojs. There is a conflict with other plugin. The issue appears for GPX or KML file? The VideoJS mine-type override should not reply, to any of the .gpx or .kml files https://github.com/xbgmsharp/piwigo-videojs/blob/master/main.inc.php#L413

Try to disable the VideoJS plugin to ensure there is no conflict. On my prod and dev box, I have both plugin and no issue.

ThomasDaheim commented 8 years ago

Happens for both gpx and kml files.

WORKS if the VideoJS plugin is disabled.