{"id":11,"date":"2010-08-26T17:23:36","date_gmt":"2010-08-26T17:23:36","guid":{"rendered":"http:\/\/www.alquier.org\/linfa\/work\/?p=11"},"modified":"2010-08-26T17:23:36","modified_gmt":"2010-08-26T17:23:36","slug":"enable-thumbnail-support-in-simplepress-and-a-multi-site-worspress","status":"publish","type":"post","link":"http:\/\/www.alquier.org\/laurent\/sites\/2010\/08\/26\/enable-thumbnail-support-in-simplepress-and-a-multi-site-worspress\/","title":{"rendered":"Enable thumbnail support in SimplePress and a multi-site WordPress"},"content":{"rendered":"<p>I was looking forward to use the thumbnail and gallery options of the\u00a0<a href=\"http:\/\/www.elegantthemes.com\/gallery\/simplepress\/\">SimplePress<\/a> theme from <a href=\"http:\/\/www.elegantthemes.com\/\">ElegantThemes<\/a>, only to find empty thumbnails when I tried it out.<\/p>\n<p>A bit of research put me on the way to a solution via &#8216;<a href=\"http:\/\/www.binarymoon.co.uk\/2009\/10\/timthumb-wordpress-mu\/comment-page-1\/#comments\" class=\"broken_link\">How to make TimThumb work with WordPress mu<\/a>&#8216;. The culprit was the difference between virtual paths and physical paths in a multi-site installation of WordPress (WordPress mu is now available by default in WordPress 3.0).<\/p>\n<p>Between this post and some of the comments, I was able to get thumbnails to work.<\/p>\n<p>1- Add a new function &#8216;get_image_path&#8217; to &#8216;SimplePress\/epanel\/custom_functions.php&#8217;, at line 149 :<\/p>\n[code]\n<p>\/* Get virtual path from post ID and full path &#8211; enable for multiple sites setup *\/<br \/>\nfunction get_image_path ($post_id = null, $theImageSrc) {<br \/>\nif ($post_id == null) {<br \/>\nglobal $post;<br \/>\n$post_id = $post-&gt;ID;<br \/>\n}<\/p>\n<p>global $blog_id, $current_site;<\/p>\n<p>if (isset($blog_id) &amp;&amp; $blog_id &gt; 0) {<br \/>\n$imageParts = explode(&#8216;\/files\/&#8217;, $theImageSrc);<br \/>\nif (isset($imageParts[1])) {<br \/>\n$theImageSrc = &#8216;http:\/\/&#8217; . $current_site-&gt;domain . $current_site-&gt;path . &#8216;wp-content\/blogs.dir\/&#8217; . $blog_id . &#8216;\/files\/&#8217; . $imageParts[1];<br \/>\n}<br \/>\n}<br \/>\nreturn $theImageSrc;<br \/>\n}<\/p>\n[\/code]\n<p>2- In the same file, add these lines at the end of &#8216;get_thumbnails&#8217;\u00a0 (before &#8216;if ($fullpath)&#8217; )<\/p>\n[code]\n<p>\/* Replace virtual path by full path &#8211; enable for multiple sites setup *\/<br \/>\n$thumb_array[&#8216;thumb&#8217;] = get_image_path($post-&gt;ID, $thumb_array[&#8216;thumb&#8217;]);<\/p>\n<p>if ($fullpath) $thumb_array[&#8216;fullpath&#8217;] = $thumb_array[&#8216;thumb&#8217;];<\/p>\n[\/code]\n<p>This should make the thumbnails available assuming you are using images loaded to the site using the Media library.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was looking forward to use the thumbnail and gallery options of the\u00a0SimplePress theme from ElegantThemes, only to find empty thumbnails when I tried it out. A bit of research put me on the way to a solution via &#8216;How to make TimThumb work with WordPress mu&#8216;. The culprit was the difference between virtual paths and physical paths in a&hellip; <\/p>\n<p><a class=\"more-link\" href=\"http:\/\/www.alquier.org\/laurent\/sites\/2010\/08\/26\/enable-thumbnail-support-in-simplepress-and-a-multi-site-worspress\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[122,1],"tags":[165,167,17],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-patches","category-uncategorized","tag-theme","tag-thumbnail","tag-wordpress","xfolkentry","clearfix"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8frwa-b","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/www.alquier.org\/laurent\/sites\/wp-json\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.alquier.org\/laurent\/sites\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.alquier.org\/laurent\/sites\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.alquier.org\/laurent\/sites\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.alquier.org\/laurent\/sites\/wp-json\/wp\/v2\/comments?post=11"}],"version-history":[{"count":0,"href":"http:\/\/www.alquier.org\/laurent\/sites\/wp-json\/wp\/v2\/posts\/11\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.alquier.org\/laurent\/sites\/wp-json\/wp\/v2\/media?parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.alquier.org\/laurent\/sites\/wp-json\/wp\/v2\/categories?post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.alquier.org\/laurent\/sites\/wp-json\/wp\/v2\/tags?post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}