nanostudio-org / nano_photos_provider2

PHP photos provider for nanogallery2
https://nanophotosprovider2.nanostudio.org/
48 stars 12 forks source link

Description not being extracted from image file names #33

Closed jpopham closed 3 years ago

jpopham commented 4 years ago

In the current release, 1.2.0, descriptions are not being extracted from image file names. I think I’ve ftraced this to a bug in the GetMetaData function of nano_photos_provider2.json.class.php At lines 948-950 we have:

if ($isImage) {
    $filename = $this->file_ext_strip($filename);
}

And a lines 955-961 we have:

$s = explode($this->config['titleDescSeparator'], $filename);
$oneItem->title = $this->CustomEncode($s[0]);
if ($isImage) {
    $oneItem->description = $this>CustomEncode(preg_replace('/.[^.]*$/', '', $s[1]));
} else {
    $oneItem->description = $this->CustomEncode($s[1]);
}

As the file name has no extension by the point of the second if ($isImage) the preg_replace has the effect of removing the description entirely. The solution is to remove the second test for $isImage and replace it with $oneItem->description = $this->CustomEncode($s[1]);

Kris-B commented 3 years ago

fixed in v1.2.2