更改 Wordpress 图像 URL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18023056/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:19:01  来源:igfitidea点击:

Change Wordpress Image URL

imagewordpresspathdirectory

提问by contool

On my wordpress site all my images are showing up as broken links. They are also showing up as broken links in the media gallery in the wordpress backend.

在我的 wordpress 网站上,我所有的图片都显示为断开的链接。它们还在 wordpress 后端的媒体库中显示为断开的链接。

I inspected the images using Google chrome and saw that they all show up like this:

我使用谷歌浏览器检查了图像,发现它们都显示如下:

<img src="http://firouzeh.co.uk/frouzeh/frouzeh/wp-content/uploads/sites/3/2013/04/Granulated-Persepolis-Ring-230x160.jpg">

there is a duplication of a file name in the path and to get the images to work I need the path to look like this:

路径中有一个文件名重复,为了使图像正常工作,我需要路径如下所示:

<img src="http://firouzeh.co.uk/frouzeh/wp-content/uploads/sites/3/2013/04/Granulated-Persepolis-Ring-230x160.jpg">

I have searched through the database and cannot find where to change the path to my images, specifically I think there must be a field somewhere that is directing everything to www.firouzeh.co.uk/frouzeh where it should just be sending it to www.firouzeh.co.uk.

我已经搜索了数据库,但找不到更改图像路径的位置,特别是我认为某处必须有一个字段将所有内容定向到 www.firouzeh.co.uk/frouzeh,它应该只是将其发送到 www .firouzeh.co.uk。

Does anyone know where to change the path?

有谁知道在哪里改变路径?

采纳答案by Kenny

If your URL settings are correct under Settings > General, then you could try using a Search and Replace plugin to update every occurrence in your database.

如果您的 URL 设置在 Settings > General 下是正确的,那么您可以尝试使用 Search and Replace 插件来更新数据库中的每个匹配项。

http://wordpress.org/plugins/search-and-replace/

http://wordpress.org/plugins/search-and-replace/

Search for firouzeh.co.uk/frouzeh/frouzeh Replace it with firouzeh.co.uk/frouzeh

搜索 firouzeh.co.uk/frouzeh/frouzeh 替换为 firouzeh.co.uk/frouzeh

Back up your site first :)

首先备份您的网站:)

If you did just move your site from another location, I suggest using the Duplicator plugin, which handles all of the replacing.

如果您只是从另一个位置移动您的站点,我建议使用 Duplicator 插件,它可以处理所有替换操作。

http://wordpress.org/plugins/duplicator/

http://wordpress.org/plugins/duplicator/

回答by Kimberly Cottrell

Use the same solution I wrote for here: https://stackoverflow.com/a/18023214/1946078

使用我在此处编写的相同解决方案:https: //stackoverflow.com/a/18023214/1946078

It is as follows:

如下:

When you move a Wordpress install, you need to also edit two fields in the database. Run this against your database in order to find the values that need to be edited:

当您移动 Wordpress 安装时,您还需要编辑数据库中的两个字段。对您的数据库运行此命令以查找需要编辑的值:

SELECT * FROM `wp_options` WHERE option_name IN('siteurl', 'home');

If database access is not an option, another way to do this is by editing your wp-config.php file to include the following two lines:

如果数据库访问不是一种选择,另一种方法是编辑您的 wp-config.php 文件以包含以下两行:

define('WP_HOME','http://yoursite.com');
define('WP_SITEURL','http://yoursite.com');

Straight from http://codex.wordpress.org/Changing_The_Site_URL

直接来自http://codex.wordpress.org/Changing_The_Site_URL

  1. The "Home" setting is the address you want people to type in their browser to reach your WordPress blog.
  2. The "Site URL" setting is the address where your WordPress core files reside.
  1. “主页”设置是您希望人们在浏览器中输入以访问您的 WordPress 博客的地址。
  2. “站点 URL”设置是您的 WordPress 核心文件所在的地址。