wordpress图像大小_如何自动删除WordPress中的默认图像链接

wordpress图像大小

WordPress makes it super easy for you to upload images and create image galleries.

WordPress使您轻松上载图像和创建图像库

However, older versions of WordPress automatically linked the image to the media file.

但是,旧版本的WordPress会自动将图像链接到媒体文件。

In this article, we will show you how to automatically remove default image links in WordPress.

在本文中,我们将向您展示如何自动删除WordPress中的默认图像链接。

Removing default image links in WordPress

Note: WordPress no longer adds default image links when you upload images to your posts or pages. However, if you are still using an older version or see this behavior on your website, then you can try the following steps.

注意:将图像上传到帖子或页面时,WordPress不再添加默认图像链接。 但是,如果您仍在使用旧版本或在您的网站上看到此行为,则可以尝试以下步骤。

为什么您应该禁用WordPress中的默认图像链接 (Why You Should Disable Default Image Links in WordPress)

By default, WordPress links images to themselves. A user sees that the image is a link, clicks it and they are then taken to the image file.

默认情况下,WordPress将图像链接到自身。 用户看到图像是一个链接,单击它,然后将其带到图像文件。

From this page the user has two options: click the ‘back’ button in their browser or move on to another site.

在此页面上,用户有两个选择:单击浏览器中的“后退”按钮或移至另一个站点。

Usually, it is the latter. It also affects your image SEO traffic because search engines could redirect users to the link used for the image instead of your post.

通常是后者。 这也会影响您的图片SEO流量,因为搜索引擎可以将用户重定向到该图片所使用的链接,而不是您的帖子。

Overall, it creates a bad user experience and affects your site’s bounce rate.

总体而言,这会带来不良的用户体验,并影响您网站的跳出率。

One solution is that you simply select the option to disable the link each time, but it is not feasible because sometimes you simply forget.

一种解决方案是,您只需选择每次禁用链接的选项,但这是不可行的,因为有时您会忘记。

Removing image link
在WordPress中删除默认图像链接 (Removing Default Image Link in WordPress)

It is very simple to disable the default image linking behavior in WordPress. However, you’ll need to add some code to your WordPress website. If you have not done this before, then take a look at our guide on how to copy and paste code snippets in WordPress.

禁用WordPress中的默认图像链接行为非常简单。 但是,您需要向WordPress网站添加一些代码。 如果您之前没有做过,请查看我们的指南, 了解如何在WordPress中复制和粘贴代码段

All you have to do is add this code snippet in your theme’s functions.php file or a site-specific plugin.

您所要做的就是将此代码段添加到主题的functions.php文件或特定站点的插件中


function wpb_imagelink_setup() {
	$image_set = get_option( 'image_default_link_type' );
	
	if ($image_set !== 'none') {
		update_option('image_default_link_type', 'none');
	}
}
add_action('admin_init', 'wpb_imagelink_setup', 10);

This code basically tells WordPress to update the image_default_link_type option and set it to ‘none’. This option is then stored in your WordPress database.

这段代码基本上告诉WordPress更新image_default_link_type选项并将其设置为“ none”。 然后,此选项存储在您的WordPress数据库中。

After adding this code, go ahead and add a new image in WordPress. You’ll notice that it no longer links to the image file or the attachment page.

添加此代码后,继续并在WordPress中添加新图像。 您会注意到它不再链接到图像文件或附件页面。

Hopefully, this will make adding images in WordPress a little less annoying specially if you never link to images.

希望这将使在WordPress中添加图像的烦恼程度减轻一些,尤其是在您从不链接到图像的情况下。

If you want to learn how to add links to an image or gallery images, then follow our guide on how to add custom links to gallery images in WordPress.

如果您想学习如何向图像或画廊图像添加链接,请遵循我们的指南,以了解如何在WordPress中向画廊图像添加自定义链接

New WordPress users may also want to see our tutorial on how to add and align images in WordPress posts and pages.

新的WordPress用户可能还希望查看我们的教程, 了解如何在WordPress帖子和页面中添加和对齐图像

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/automatically-remove-default-image-links-wordpress/

wordpress图像大小

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值