WordPress.org

Ready to get started?Download WordPress

Forums

add-rel-lightbox
[resolved] Warning preg_replace (8 posts)

  1. Agnes
    Member
    Posted 2 years ago #

    I get this error when searching with relevanssi (a search that will return result with images):

    Warning: preg_replace() [function.preg-replace]: Unknown modifier 'C' in \wp-content\plugins\add-rel-lightbox\add_rel_lightbox.php on line 61

    Any idea?

    http://wordpress.org/extend/plugins/add-rel-lightbox/

  2. Agnes
    Member
    Posted 2 years ago #

    The strange thing is I get this on some searches but not all...

  3. Agnes
    Member
    Posted 2 years ago #

    I uinderstoofd then it has to do with what it finds in my results and how it transforms it.

    So I removed the reference to the tithe in the lines:

    // $pattern = "/<a href='(.*?).(jpg|jpeg|png|gif|bmp|ico|svg)' title='" . $attachment->post_title . "'><img(.*?)class=\"attachment-thumbnail\"(.*?)\/><\/a>/i";

    for

    $pattern = "/<a href='(.*?).(jpg|jpeg|png|gif|bmp|ico|svg)'><img(.*?)class=\"attachment-thumbnail\"(.*?)\/><\/a>/i";

    And also

    //$replace = '<a href="${1}.${2}" rel="prettyPhoto[post-' . $id . ']" title="' . $caption . '"><img${3}class="attachment-thumbnail"${4}/></a>';
    for
    $replace = '<a href="${1}.${2}" rel="prettyPhoto[post-' . $id . ']"><img${3}class="attachment-thumbnail"${4}/></a>';

    If someone knows better, I'd do!

  4. DefProc
    Member
    Plugin Author

    Posted 2 years ago #

    Hmmm... The most likely thing is the title content is breaking the regexes. Version 0.4 doesn't use regexes to do the page parsing, so it might be more robust.

    If you send a copy of the page content that causes the error, I'll take a look and see what's causing the problem. You can email it to me at (contact [at] def-proc.co.uk) if you'd rather not post it publically here.

  5. Agnes
    Member
    Posted 2 years ago #

    Hi DefProc,
    It was on a prod site here
    http://www.morija.co.ls/morija/?s=hat&post_type=objects
    (demo/demo)
    I have just restored the unmodified file of the plugin so you can seee the error. Please tell me what you think!
    Thanks,
    Agnes

  6. Agnes
    Member
    Posted 2 years ago #

    When the error is on on the page above, the re is no excerpt for the 1st item "basotho hat"
    On my local version with a modified version of the plugin where I dont get the error, I get the excerpt and that is:

    Basotho Hat
    It is a beautiful hat that is made from various types of grasses. Basotho wore these ha...

    So it seems something in this text is causing the replace function to fail... Is it that the last word ("hat") is cut?

  7. DefProc
    Member
    Plugin Author

    Posted 2 years ago #

    Yep, from a quick look, my best guess is that it's the lack of the precision in the gallery regex. I can't be sure without seeing the page content without add-rel-lightbox activated, to see if it has changed anything, but the gallery regex *shouldn't* match for this page.

    I think that instead of matching:

    <a […]><img […]></a>

    it's actually matching:

    <a […]></a>
    […]
    <img […]>
    […]
    <a […]></a>

    and because the extra content has some unescaped /s in it, it's breaking the /(pattern)/i and adding a /c inside the pattern. This is an example of why regexes are bad for parsing HTML and why the plugin hasn't reached version 1 yet.

    I've changed to DOM parsing in version 0.4, so the see if an upgrade sorts it out.

  8. Agnes
    Member
    Posted 2 years ago #

    I can't really follow you that far!
    But I'll now revert the version with my above fix (and by the way that lets you see the page without that mistake)
    It is still here:
    http://www.morija.co.ls/morija/?s=hat&post_type=objects
    The stragne thing is, the same code for the "zoom" where the rel lightbox is used works also here:
    http://www.morija.co.ls/morija/museum/collections/
    I dont get why with the serach function (I guess because of highlighting the search terms) it does not sometimes... This is using Relevanssi by the way.
    Also, I am passing a number of HTML colde in the zoom link, may be then it gets wild...
    A1nyhow.. the fox does for me.
    Thanks!
    Agnes

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.