<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>远程图片保存到本地 &#8211; 壹资源网</title>
	<atom:link href="https://www.iezyw.com/html/tag/%E8%BF%9C%E7%A8%8B%E5%9B%BE%E7%89%87%E4%BF%9D%E5%AD%98%E5%88%B0%E6%9C%AC%E5%9C%B0/feed" rel="self" type="application/rss+xml" />
	<link>https://www.iezyw.com</link>
	<description>一个降低试错成本的网站！</description>
	<lastBuildDate>Wed, 17 Apr 2024 06:25:34 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.iezyw.com/wp-content/uploads/2026/01/cropped-logo-5-32x32.png</url>
	<title>远程图片保存到本地 &#8211; 壹资源网</title>
	<link>https://www.iezyw.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>wordpress发布文章自动把远程图片保存到本地的两个方法</title>
		<link>https://www.iezyw.com/html/20248522.html</link>
		
		<dc:creator><![CDATA[壹资源网]]></dc:creator>
		<pubDate>Wed, 17 Apr 2024 06:11:44 +0000</pubDate>
				<category><![CDATA[网站源码]]></category>
		<category><![CDATA[QQworld]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress图片保存]]></category>
		<category><![CDATA[远程图片保存到本地]]></category>
		<guid isPermaLink="false">https://www.iezyw.com/?p=8522</guid>

					<description><![CDATA[现今，使用WordPress程序搭建个人站点蔚然成风，其简易的操作界面与高度的用户友好性备受青睐，使得即便对编 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>现今，使用WordPress程序搭建个人站点蔚然成风，其简易的操作界面与高度的用户友好性备受青睐，使得即便对编程代码知之甚少的人也能轻而易举地创建出如“楚狂人博客”般独具特色的个人网站。</p>
<p>在此背景下，今日特与诸位探讨两种实用技巧，旨在解决在WordPress发布文章时自动将远程图片导入本地服务器的难题。众所周知，尽管诸多网站并非全然依赖原创内容，但在转载优质文章的过程中，常遭遇源站对图片实施防盗链保护，导致逐图下载、手动上传的过程繁琐不堪。所幸，下述两种方法能有效地简化这一流程，助您一键式将心仪文章中的图片无缝整合至自家网站，省时省力，提升内容管理效率。</p>
<h3>一、第一个方法是使用插件：QQworld</h3>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-8523" title="yuancheng-chajian-1" src="https://www.iezyw.com/wp-content/uploads/2024/04/yuancheng-chajian-1.jpg" alt="yuancheng-chajian-1" width="720" height="123" /></p>
<h3>方法二：使用自定义代码</h3>
<p>如果你更倾向于使用自定义代码来实现这一功能，你可以使用以下代码将远程图片自动保存到本地。在你的主题的functions.php文件中加入以下代码：</p>
<pre class="brush:php;toolbar:false">function auto_save_remote_images($content) {
    preg_match_all('/&lt;img[^&gt;]+src="([^"]+)"[^&gt;]*&gt;/', $content, $matches);
    if ($matches) {
        foreach ($matches[1] as $img_url) {
            $upload_dir = wp_upload_dir();
            $img_path = $upload_dir['path'] . '/' . basename($img_url);
            $img = file_get_contents($img_url);
            file_put_contents($img_path, $img);
            $content = str_replace($img_url, $upload_dir['url'] . '/' . basename($img_url), $content);
        }
    }
    return $content;
}
add_filter('the_content', 'auto_save_remote_images');

</pre>
<p>这段代码将在文章发布时自动将远程图片保存到本地服务器，并更新文章内容中的图片链接。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
