Support » Plugin: Auto Post Thumbnail » Fixing apt_generate_post_thumb() to handle image URLs with querystrings

  • Resolved mrboson


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

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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!

    Plugin Author tariquesani


    Nicely done!

    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 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?



    I meant to type:

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

    Plugin Author tariquesani



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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Fixing apt_generate_post_thumb() to handle image URLs with querystrings’ is closed to new replies.