• If I upload a photo to media gallery and insert it into a post it is now automatically having a link rel added in this form:

    link rel=attachment wp-att-(some-id-number)

    This is playing havoc with NextGen’s ability to open media thumbs with its own lightbox.
    Error console gives:
    Error: Syntax error, unrecognized expression: a[rel=attachment wp-att-15239], area[rel=attachment wp-att-15239]

    Does anyone know what is causing the Link rel to be added and how I can stop it?

Viewing 6 replies - 1 through 6 (of 6 total)
  • In the text option in the editor you can remove the link manually and remain the image

    Thread Starter digbymaass

    (@digbymaass)

    Yes I know. We add new images all the time so I can’t be removing it manually. I need to know what has suddenly started adding it and how to stop it.

    Thread Starter digbymaass

    (@digbymaass)

    I reverted the whole localhost installation (which is displaying the same problem as the live site) to before the latest WP update and the link rel is not added to images.
    Then I updated to the latest version of WP in the reverted installation and link rel is again added to images.

    So something in wordpress 4.4 is doing it

    I’ve noticed the same issue since upgrading to WordPress 4.4, too. Kind of a pain to have to manually delete the rel= string for each image in a post.

    Anyone have a solution?

    Thread Starter digbymaass

    (@digbymaass)

    Adding this to functions.php stops it getting added to new images:

    add_filter('image_send_to_editor', 'wpse_88984_remove_rel', 10, 2);
    function wpse_88984_remove_rel($html, $id) {
        if($id>0)
            $html=str_replace('rel="attachment wp-att-'.$id.'"','',$html);
    
        return $html;
    }

    But my attempt to find already loaded images in the database and delete the link rels with an SQL search and replace didn’t work. My syntax is undoubtedly wrong…

    update wp_posts set post_content = replace(
    post_content, 'rel="attachment wp-att-[0-9]*"',
    '');

    Thanks for the filter solution. It works nicely.

    Here’s a database query to update your existing posts in one go. It only works on MariaDB, there is no simple solution for this in MySQL because it doesn’t have support for regular expression replace.

    UPDATE wp_posts SET post_content = regexp_replace(post_content, ' rel="attachment wp-att-[0-9]+"', '') where post_content REGEXP 'rel="attachment wp-att-[0-9]+"';
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Media thumbs suddenly have Link rel attribute’ is closed to new replies.