Fixing apt_generate_post_thumb() to handle image URLs with querystrings
-
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)
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.