WordPress.org

Ready to get started?Download WordPress

Forums

Auto Post Thumbnail
[resolved] Fixing apt_generate_post_thumb() to handle image URLs with querystrings (6 posts)

  1. mrboson
    Member
    Posted 1 year ago #

    The apt_generate_post_thumb() function is unable to handle the case where a source image URL includes a querystring argument. In that case, the call to WordPress wp_unique_filename() function strips the invalid characters out of the querystring, but leaves alphanumeric characters that will be appended to the extension. The result can be a name that might not be recognized as a valid image type.

    The solution is to strip the querystring off before calling wp_unique_filename().

    Replace line 303 of apt_generate_post_thumb() with the following:

    $filename = parse_url($imageUrl, PHP_URL_PATH);
        $filename = substr($filename, (strrpos($filename, '/'))+1);

    http://wordpress.org/extend/plugins/auto-post-thumbnail/

  2. psordi
    Member
    Posted 1 year ago #

    Very useful hack: it allows to generate automatic thumbs from Flickr, for example. With the last update of the plugin it was not possible anymore. Thanks!

  3. tariquesani
    Member
    Plugin Author

    Posted 1 year ago #

    Nicely done!

  4. gavinbrooks
    Member
    Posted 1 year ago #

    I bought this app but am having difficulties with it and cannot find proper support, I bought from codecanyon and they sent me on a wild goose chase to a forum that does not provide support and to a broken link.

    Anyway perhaps you can help me please? Have a look here http://irolex.co.uk/ and note the missing thumbnails.

    I deleted the thumbnails and ran the generator again but the problem is still there.

    I thought of trying the suggestion from mrboson with his code snippet but I cannot locate the file he is referring to.

    Any ideas please?

    Regards
    Gavin

  5. mrboson
    Member
    Posted 1 year ago #

    Gavin,

    I meant to type:

    Change the apt_generate_post_thumb() function:
    Replace line 303 of auto-post-thumbnail.php with ...

  6. tariquesani
    Member
    Plugin Author

    Posted 1 year ago #

    Gavin,

    You did get to us finally and please don't post support request about commercial products here... Not allowed

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic