{"id":4085482,"date":"2013-09-01T02:59:01","date_gmt":"2013-09-01T02:59:01","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/bug-in-thumbnailerincphp-with-fix-attached\/"},"modified":"2016-08-21T04:29:37","modified_gmt":"2016-08-21T04:29:37","slug":"bug-in-thumbnailerincphp-with-fix-attached","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/bug-in-thumbnailerincphp-with-fix-attached\/","title":{"rendered":"Bug in thumbnailer.inc.php (with fix)"},"content":{"rendered":"<p>Hello Dan,<\/p>\n<p>We have a few tickets in our support desk for a WP-Portfolio bug that was uncovered due to a recent change in our system (http:\/\/www.shrinktheweb.com\/content\/now-inside-pages-are-automatic-when-upgraded.html).<\/p>\n<p>In order for &#8220;Inside Pages&#8221; to work automatically, we must assume that &amp;stwurl is the last parameter in the request. This has always been recommended &#8220;Best Practice&#8221; but now it is mandatory for all requests. Based on a comment in your code, it looks like you took this into account originally. However, somewhere along the way, you added an $args[&#8216;filetype&#8217;] AFTER the &amp;stwurl. <\/p>\n<p>The downside is that not following the guideline of &amp;stwurl being last means that the request will fail with error &#8220;Invalid Characters in Domain Name.&#8221;<\/p>\n<p>Fortunately, the fix is simple:<\/p>\n<p>Open the file:<br \/>\n\/wp-content\/wp-portfolio\/lib\/thumbnailer.inc.php<\/p>\n<p>FIND THESE LINES:<\/p>\n<p>\/\/ Add arguments not yet added<br \/>\n$args[&#8220;Service&#8221;] = &#8220;ShrinkWebUrlThumbnail&#8221;;<br \/>\n$args[&#8220;Action&#8221;] = &#8220;Thumbnail&#8221;;<br \/>\n$args[&#8220;stwurl&#8221;] = $url; \/\/ now url is added to the parameters at the end<\/p>\n<p>\/\/ Check the error cache for the error rather than do a fresh request.<br \/>\n\/\/ If there&#8217;s an error, return the cached error rather than wasting a request<br \/>\n$cachedError = WPPortfolio_errors_checkForCachedError($args, $pendingThumbPath);<br \/>\nif ($cachedError) {<br \/>\nreturn $cachedError;<br \/>\n}<\/p>\n<p>$actualThumbPath = trailingslashit($actualThumbPath);<\/p>\n<p>$type = strtolower(substr(strrchr($url, &#8216;.&#8217;), 0));<\/p>\n<p>$args[&#8216;filetype&#8217;] = $type;<\/p>\n<p>REPLACE WITH:<\/p>\n<p>\/\/ Check the error cache for the error rather than do a fresh request.<br \/>\n\/\/ If there&#8217;s an error, return the cached error rather than wasting a request<br \/>\n$cachedError = WPPortfolio_errors_checkForCachedError($args, $pendingThumbPath);<br \/>\nif ($cachedError) {<br \/>\nreturn $cachedError;<br \/>\n}<\/p>\n<p>$actualThumbPath = trailingslashit($actualThumbPath);<\/p>\n<p>$type = strtolower(substr(strrchr($url, &#8216;.&#8217;), 0));<\/p>\n<p>$args[&#8216;filetype&#8217;] = $type;<\/p>\n<p>\/\/ Add arguments not yet added<br \/>\n$args[&#8220;stwurl&#8221;] = $url; \/\/ now url is added to the parameters at the end<\/p>\n<p>***** END FIX *****<\/p>\n<p>I also removed two deprecated $args just to keep the code\/requests clean.<\/p>\n<p>https:\/\/wordpress.org\/plugins\/wp-portfolio\/<\/p>\n","protected":false},"template":"","class_list":["post-4085482","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4085482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4085482\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=4085482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}