Support » Plugin: ImageFX » .jpeg extension messes up things ( fix)

  • First of all i’d like to thank you for developing this plugin!

    It works fine for me, except for one thing: images with extension “.jpeg” are named wrongly by the plugin. For example, if i want to create greyscale versions of my thumbnails (besides the coloured versions), and i add the slug “-bw”, the naming of the files goes like this:

    imageA-400×300.jpg -> imageA-400×300-bw.jpg
    imageB-400×300.jpeg -> imageB-400×300.-bwjpeg

    Apparently the slug is inserted before the last 4 characters of the filename, which doesn’t take into account the “jpeg” extension.

    I looked into imagefx.php and saw where this happens. I changed lines 430-431 from this

    $newfile = substr( $file, 0, -4 ) . '-' . $slug . substr( $file, -4 );
    $info['file'] = substr( $info['file'], 0, -4 ) . '-' . $slug . substr( $info['file'], -4 );

    to this

    $filename_parts = explode('.', $file);
    $extension = array_pop($filename_parts);
    $newfile = implode('.', $filename_parts) . '-' . $slug . '.' . $extension;
    $filename_parts = explode('.', $info['file']);
    $extension = array_pop($filename_parts);
    $info['file'] = implode('.', $filename_parts) . '-' . $slug . '.' . $extension;

    and now it works fine. (I’m sure my code can be rewritten in a better way, but i don’t know exactly what $file and $info[‘file’] exactly contain.)

    Keep up the good work!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Samuel Wood (Otto)

    (@otto42) Admin

    A simpler solution would be to rename your files to “jpg” before uploading them. The “jpeg” extension is non-standard and not supported by a wide variety of software.

    Could be, but the website is for a client, not for myself. Several people will be uploading images to the website and i can’t tell them all not to upload .jpeg images 🙂

    Plugin Author Samuel Wood (Otto)

    (@otto42) Admin

    I would not recommend using this plugin for a client’s site or anything other than testing or on your own personal site. It was made as a proof of concept only, and I make no guarantees that it will work in the future.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘.jpeg extension messes up things ( fix)’ is closed to new replies.