Files with double extensions when uploading to Gallery3 from GalleryRemote - NOT GalleryRemote

CalgarySteve

Joined: 2012-01-11
Posts: 21
Posted: Sat, 2012-03-10 21:11

Hi,

I almost always use GalleryRemote to upload photos to Gallery3 (3.0.2 (Coollanta)) primarily because of the "Auto Rotate" functionality.

To that end, I have worked with the author of the G3 GalleryRemote module to resolve a few issues and it's working great now.

The only outstanding issue I have is that the images end up in the album (on the hard disk) with what I would call "double extensions" as the filename

For example,
DSCN0983.JPG-1493161548.jpeg
DSCN0983.JPG.jpeg

Everything still works fine, but I do not like having the "double extensions".

Given that I have only imported images from G2 and used GalleryRemote, I assumed that this was a problem with GalleryRemote.

However, I have tracked the problem down to the core Gallery3 code:
modules/gallery/models/item.php

On approximately line 365, there is some code:
// Force an extension onto the name if necessary

$pi = pathinfo($this->data_file);
if (empty($pi["extension"])) {
$this->name = "{$this->name}.$extension";

The main problem is that "data_file" contains a temporary filename (from the upload) such as:
date_file = [/tmp/phpJ8bzPfS3fY] and therefore will NEVER have an extension.

I changed the code to
$pi = pathinfo($this->name);
if (empty($pi["extension"])) {
$this->name = "{$this->name}.$extension";

And it has resolved the problem. Files uploaded to G3 (only tested with GalleryRemote) are stored in the library WITHOUT a double extension.
eg:
DSCN0984.JPG.jpeg
is now saved as:
DSCN0984.JPG

I did not want to file a bug until I had confirmed that this is actually a bug instead of working "as designed".

Thanks,
Steve Williams