• Resolved rmose

    (@rmose)


    As discussed in

    http://wordpress.org/support/topic/plugin-shortcodes-ultimate-carousel-gallery-and-nivo-dont-work-on-multisite-installations?replies=16

    there is a problem with multisite installations. The issue is that TimThumb is being called with the pretty URL of the image. TimThumb is a general tool and has no understanding of the mapped directory structure in a WordPress multisite installation. As a result, it makes some assumptions that are not valid in this situation.

    Either a WordPress-aware alternative should be used, or more details have to be provided to TimThumb. The second option is not desirable, because it exposes the internal directory structure to the Internet and unmaps pretty URLs. TimThumb isn’t really the right tool to use here, but given that it is being used, the plugin or theme writer has to generate the proper information for TimThumb.

    The solution below is based on the fix I developed for vSlider and discussed here.

    wordpress.org/support/topic/plugin-vslider-multi-image-slider-for-wordpress-multisite-patch-for-vslider-to-use-timthumb

    Modify shortcodes-ultimate.php by inserting the code for the following function anywhere in the file along with the other functions.

    /**
             * If the blog_id is defined (i.e., multisite) and the
             * given URL references a files directory, return
             * the URL with the initial part replaced with the
             * specific path to the current blog's files.
             */
            function su_replace_blogpath($url) {
                    global $blog_id;
                    if (isset($blog_id) && $blog_id > 0) {
                            $blogs_dir = '/blogs.dir/' . $blog_id;
                            $image_parts = explode('/files/', $url);
                            if (isset($image_parts[1])) {
                                    $url = $blogs_dir . '/files/' . $image_parts[1];
                            }
                    }
                    return $url;
            }

    Then, enter the lib directory and update images.php, media.php and shortcodes.php. Search for the lines with timthumb that look like

    '/lib/timthumb.php?src=' . $something . $something_else

    and change them to

    '/lib/timthumb.php?src=' . su_replace_blogpath($something) . $something_else

    For example, line 55 of images.php looks like

    'thumbnail' => su_plugin_url() . '/lib/timthumb.php?src=' . $attachment->guid . '&w=' . $width . '&h=' . $height . '&zc=1&q=100',

    Add the call to su_replace_blogpath() around $attachment->guid so that the specific blog path will be used rather than the pretty URL.

    'thumbnail' => su_plugin_url() . '/lib/timthumb.php?src=' . su_replace_blogpath($attachment->guid) . '&w=' . $width . '&h=' . $height . '&zc=1&q=100',

    The tests here have been successful on a multisite, but it should be tested further to be sure that it works as expected for everyone.

    http://wordpress.org/extend/plugins/shortcodes-ultimate/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Shortcodes Ultimate] Multisite patch to use TimThumb’ is closed to new replies.