WordPress.org

Ready to get started?Download WordPress

Forums

ImageFX
.jpeg extension messes up things (+ fix) (4 posts)

  1. Lisa
    Member
    Posted 7 months ago #

    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-400x300.jpg -> imageA-400x300-bw.jpg
    imageB-400x300.jpeg -> imageB-400x300.-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!

    http://wordpress.org/plugins/imagefx/

  2. Samuel Wood (Otto)
    Tech Ninja
    Plugin Author

    Posted 7 months ago #

    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.

  3. Lisa
    Member
    Posted 7 months ago #

    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 :)

  4. Samuel Wood (Otto)
    Tech Ninja
    Plugin Author

    Posted 7 months ago #

    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.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.