• I added a facebox plugin to my site and noticed some problems.

    The facebox code doesn’t check if the image already has a ‘rel’.

    Images added before the the facebox plugin was activated or images that use a caption seem to have a rel added by wordpress and so the facebox plugin doesn’t do it’s thing.

    My fix is to edit

    wp-content/plugins/wp-facebox/wp-facebox.php

    and replace

    [code]
    function rel_replace( $content ) {
    $pattern = "/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>(.*?)<\/a>/i";
    $replacement = '<a$1href=$2$3.$4$5 rel="facebox"$6>$7';
    $content = preg_replace($pattern, $replacement, $content);
    return $content;
    }
    [/code]
    with

    [code]
    function rel_replace( $content ) {

    $mystring = $content;
    $findme = 'rel="';
    $pos = strpos($mystring, $findme);

    if ($pos === false) {
    $pattern = "/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>(.*?)<\/a>/i";
    $replacement = '<a$1href=$2$3.$4$5 rel="facebox"$6>$7';
    $content = preg_replace($pattern, $replacement, $content);
    } else {
    $content = str_replace('rel="','rel="facebox ',$content);
    }

    return $content;

    }
    [/code]

    I should stress that this is my experience and my solution – it may work for you if you notice the problem I was having

  • The topic ‘Facebox plugins rel issue – fix’ is closed to new replies.