You need to hook into the image_send_to_editor filter. This allows you to modify the markup used when inserting an image into the content editor.
Something like this should work:
add_filter('image_send_to_editor', 'my_add_rel_nofollow', 10, 8);
function my_add_rel_nofollow($html, $id, $caption, $title, $align, $url, $size, $alt="" ){
// check if there is already a rel value
if ( preg_match('/<a.*? rel=".*?">/', $html) ) {
$html = preg_replace('/(<a.*? rel=".*?)(".*?>)/', '$1 ' . 'nofollow' . '$2', $html);
} else {
$html = preg_replace('/(<a.*?)>/', '$1 rel="' . 'nofollow' . '" >', $html);
}
return $html;
}
This will first check if there is already a rel
attribute, and add the no_follow. Or, if there is no rel
attribute, it will add one, and set it to nofollow
.
Related Posts:
- Change the output for [gallery] shortcode
- How to add php to theme to show alt attributes
- How to Display an Image Uploaded through a Meta Box in a Template?
- Featured Images on Front Page
- Display different header images based on current page
- Why is wordpress searching for @2x images?
- Custom page template to display all image attachments
- Is There A Way Of Using the_post_thumbnail() to Pull In A Specific Image From The Media Library
- How to create ‘Local’ filters for WordPress srcset sizes in template parts?
- how to move from content and place them elsewhere on a page template?
- HowTo: develop WP template with dynamic background image
- Apply nextgen-gallery lightbox effect [closed]
- How to Featured content with images in home page?
- How to create a title images for different posts?
- How to get rid of undefined variable in previous post image
- How to add php to theme to show alt attributes
- second featured post not displaying on page [closed]
- Display images in template file
- Show uploaded images in full size
- Automatically replace original uploaded image with large image size
- How to scale up featured post thumbnail?
- Custom image size / thumbnail – Crop to aspect ratio even when source image is smaller than set dimensions
- wp_get_attachment_image_src and server path
- Change WordPress image URLs via filter
- How to resize images in wordpress without adding any compression or changing the color profile of the images, possible?
- hook into completed image upload filter
- How to quickly switch custom post type singular template?
- Why is wp_get_attachment_image not including “full” size in srcset?
- Get img alt tag from a Image that has been uploaded through the Customizer
- Get Attachment ID from URL [duplicate]
- How to set twenty fourteen header image at 100% width?
- Can’t Display Featured Image in RSS Feed
- Filter to modify post_title after image upload?
- Automatically Add Caption in image
- Import Images from one self-hosted WordPress install to another
- How to Optimize images after uploading all images to WordPress Site?
- How to get relative URL of medium sized featured image?
- How do i reference the theme path in pages for images?
- How to move style from template file to section?
- Using srcsets to load different images based on browser widths
- Multiple entries for one object with different cover images
- How to exclude an image size from the WordPress srcset
- Get full URL of images in media library including http://
- Creating new templates in child themes breaks layout
- Generating different dimension images while uploading image file from custom plugin page
- How to intigrate multiple image uploader in a custom post type
- Stripping the_content() from images then displaying them seperately
- Image upload appearing as broken images following server move
- renaming an image automatically everywhere else (posts and pages)
- Change wp-content/uploads to uploads/%postname%/%image%
- Does wp_get_attachment_image_src also work with non-image files?
- Why does WP allow to view and media item as a page
- Console Browser says it cannot find a requested image that does not exist on my Website [closed]
- What template is used for viewing Media Library Files?
- Display attached images as background-image css
- Remove Additional image sizes created by theme
- Show Image Size as Dragging it Larger or Smaller
- Logo on the tab
- Custom permalink structure for remote content pages
- How to display a sized image from Simple Fields repeatable field
- Allow admin roles to add images to comment replies
- Calling two images at a time? A better way?
- Random Characters in the end of every image url in post
- Image.php Problem – Post Images Not Displaying In It
- Broken thumbnails (sometimes) with TimThumb
- Can i have 2 separate Galleries on 2 separate pages each go to a DIFFERENT Attachment.php file?
- Is it possible to save crop to a different size of the image when in image editor?
- How do you change the fetched image of a PDF uploaded into WordPress Media Library?
- Apply manual image cropping not to thumbnail but medium_large size
- Hide or mask the url to an image
- Trying to change the URL of a product image once I upload it, but there seems to be no way to access the URL
- Trouble with Uploading and Displaying Images
- How can I insert and display copyright owner field on featured-images, pictures and galleries in articles?
- Image alt attribute
- wp_download_url() for dynamically generated image
- Non-existent child page URLs redirects to the image attachment URL instead of throwing 404
- Images not loading on wordpress.org site
- How to change img src in home-made theme, using WordPress` live customizer?
- Full size image from srcset ALWAYS used on mobile DESPITE setting size of image in editor
- WordPress not choosing the right image from srcset
- how to remove / hide ‘featured image’ option from side menu
- How to get attachements URL from author meta and display them?
- How can I set different banner images using background cover at different breakpoints?
- Replacing an Image gallery
- Missing Images in Uploads Directory (Server Only)
- Is there a way to share a template/markup with the JSON API so that it doesn’t need to be declared both in PHP and in JS?
- Images with excerpt function
- Why is WordPress loading a different sized post thumbnail?
- Uploading Full Size Image vs Resizing Before Upload
- Img alt tag showing different value then entered
- Adding Multiple Images to Sidebar Through Dashboard
- How to hide image alt text/caption in Visual Composer?
- Delete all thumbnails & regenerate them?
- Can I turn an image into a button?
- Why are some SVG-images not visible in my footer?
- How To Get Feature Image from Blog in Same WordPress Multisite Blog on the Parent Blog?
- WPALLIMPORT Exporting images from repeater field [closed]
- What is the point of using the front-page.php template? [closed]
- image_get_intermediate_size always returns false
- Change of displayed images for webp versions