In the text option in the editor you can remove the link manually and remain the image
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.
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?
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]+"';