0

Wordpress automatically adds the link to every image I upload within Media. And then I can’t find a way to remove it. How can I upload images without links or just remove it? There is just no option to choose whether to upload with link or without. I tried many plugins for that but none seems to be working. This happens when I use uploaded images in default Gallery widget by Wordpress. I also tried this code, but nothing. Code:

add_filter( 'the_content', 'attachment_image_link_remove_filter' );
function attachment_image_link_remove_filter( $content ) {
$content =
preg_replace(
array('{<a(.*?)(wp-att|wp-content\/uploads)[^>]*><img}',
'{ wp-image-[0-9]*" /></a>}'),
array('<img','" />'),
$content
);
return $content;
}
  • Why are you trying to remove the link? What is the end goal? – disinfor Feb 22 '18 at 18:05
  • @disinfor Because now I can click on the image and it takes me to another page. I dont want images to be clickable – Limpuls Feb 22 '18 at 18:15
  • If you use Wordpress/Yoast SEO (and who doesn't) then this is option is available in the plugin. – Beee Feb 22 '18 at 22:53
4

You adjust that when you insert the image into the post, not when you upload it.

When you upload the image, you will be looking at it on the Media Library page. On the right hand side is a column that says "ATTACHMENT DETAILS". Scroll down on that, and look for "ATTACHMENT DISPLAY SETTINGS".

The field you're looking for is called "Link To" and you want to set it to be "None" before you click the "Insert into Post" button.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.