WordPress.org

Ready to get started?Download WordPress

Forums

Thumbnail For Excerpts
Fix for thumbnails when filenames have more than one hyphen (WordPress iOS App) (1 post)

  1. jegelstaff
    Member
    Posted 1 year ago #

    Hello,

    This is a very handy plugin, works almost perfectly out of the box. I found a problem though.

    When I added an image to a post, and I picked the medium size version of an image from my library, then the image name that was put into the post was blahblahblah-blahblah-225x400.jpg

    I added the original image to the library at a previous point in time, and then selected the medium size of it for my post. So that's the filename that was used. It was originally generated by an upload from the iOS WordPress app, so I expect this issue is somewhat common.

    The bottom line is, there's a regular expression match around line 221 that looks like this:

    preg_match_all('~(\w*)-([0-9]*)x([0-9]*).('.$type.')~', $src, $matches);

    I found that it was getting tripped up by the presence of more than one hyphen in the name. I changed it to this and it seemed to fix the issue:

    preg_match_all('~([\w\-]*)-([0-9]*)x([0-9]*).('.$type.')~', $src, $matches);

    Explanation: \w* matches one or more "word characters" (which is digits, letters and underscores), while [\w\-]* adds hyphens to the set of characters that are matched.

    Presumably other unusual punctuation in filenames might continue to throw off the parser. But anyway, this is a fix that resolves the problem at least for images sent up from the iOS WordPress app. I hope it helps someone else.

    --Julian

    http://wordpress.org/extend/plugins/thumbnail-for-excerpts/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic