Bug/Feature when image_convert is enabled

See all posts Reply

Bug/Feature when image_convert is enabled new!
by C. Miko, 17 years, 2 months ago
Hi Colin-

I noticed that when auto-converting images to a specified type (.png, .jpeg, etc.), the 'file_dest_ext' returns an incorrect value after processing is complete.

e.g. if I upload 'foo.jpg' and set image_convert = 'png', the image is saved as 'foo.png' but 'file_dest_ext' post-process returns 'jpg'.

Not sure if this is the intended effect, but for scripts that attempt to upload a file, then save info about the file to a DB, it helps if 'file_dest_ext' reflects the image type conversion. Code in question starts around line 2,873.

Thanks for the script,

--ChadReply
Re: Bug/Feature when image_convert is enabled new!
by colin, 17 years, 2 months ago
You are right, there is a bug. The bug is around line 1950.

To fix it, you can replace the following code:
if ($this->image_convert=='') {
  $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : '');
  $this->log .= '- ' . _("image operation, keep extension") . '
'; } else { $this->file_dst_name = $this->file_dst_name_body . '.' . $this->image_convert; $this->log .= '- ' . _("image operation, change extension for conversion type") . '
'; }
with:
if ($this->image_convert=='') {
  $this->file_dst_name = $this->file_dst_name_body . (!empty($this->file_dst_name_ext) ? '.' . $this->file_dst_name_ext : '');
  $this->log .= '- ' . _("image operation, keep extension") . '
'; } else { $this->file_dst_name = $this->file_dst_name_body . '.' . $this->image_convert; $this->file_dst_name_ext = $this->image_convert; $this->log .= '- ' . _("image operation, change extension for conversion type") . '
'; }
Thanks for pointing it out. It will be fixed in the next release.Reply