<?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>图片相关文章列表 | 皇家元林</title>
	<atom:link href="https://hjyl.org/tags/%E5%9B%BE%E7%89%87/feed/" rel="self" type="application/rss+xml" />
	<link>https://hjyl.org</link>
	<description>刘元林的个人博客</description>
	<lastBuildDate>Sat, 07 Dec 2024 04:49:54 +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://img.hjyl.org/uploads/2019/10/cropped-about-me-32x32.png</url>
	<title>图片相关文章列表 | 皇家元林</title>
	<link>https://hjyl.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>wp_get_attachment_image_src获取不到文章附件？</title>
		<link>https://hjyl.org/wp-get-attachment-image-src-get-photos/</link>
					<comments>https://hjyl.org/wp-get-attachment-image-src-get-photos/#comments</comments>
		
		<dc:creator><![CDATA[皇家元林]]></dc:creator>
		<pubDate>Sat, 07 Dec 2024 04:47:56 +0000</pubDate>
				<category><![CDATA[元林手札]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[wp_get_attachment_image_src]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[媒体库]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[文章附件]]></category>
		<category><![CDATA[相册]]></category>
		<guid isPermaLink="false">https://hjyl.org/?p=5572</guid>

					<description><![CDATA[今天无意打开博客相册，发现最近文章里的图片没有获取到，仅是最近一篇文章里的，所以我猜是那篇文章的问题。我依稀记 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>今天无意打开博客<a href="https://hjyl.org/photos/">相册</a>，发现最近文章里的图片没有获取到，仅是最近一篇文章里的，所以我猜是那篇文章的问题。我依稀记得当时是先上传图片到媒体库，然后插入到文章里的。难道这还有区别？果然，我发现了不一样。</p>



<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1408" height="726" data-id="5574" src="https://img.hjyl.org/uploads/2024/12/wechat_2024-12-07_094004_287.png"  class="wp-image-5574" title="wechat_2024 12 07_094004_287.png" alt="wechat_2024 12 07_094004_287.png" /></figure>



<figure class="wp-block-image size-large"><img decoding="async" width="1412" height="714" data-id="5573" src="https://img.hjyl.org/uploads/2024/12/wechat_2024-12-07_093912_340.png"  class="wp-image-5573" title="wechat_2024 12 07_093912_340.png" alt="wechat_2024 12 07_093912_340.png" /></figure>
</figure>



<p>这就过分了。所以说需要数据库支持的相册就是很麻烦。我不能一个个删掉再重新上传吧。那只能修改数据库咯。</p>



<h3 class="wp-block-heading">查找数据库</h3>



<p>媒体和文章一样，都在wp_posts表里，sql查询可得：</p>



<pre class="wp-block-code"><code lang="sql" class="language-sql line-numbers">Select * from wp_posts where post_type = 'attachment';</code></pre>



<p>最多显示500条，你可以导出来看，我就是这么干的，然后用文本编辑器打开都能看。</p>



<figure class="wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><img decoding="async" width="866" height="498" data-id="5577" src="https://img.hjyl.org/uploads/2024/12/wechat_2024-12-07_094047_352.png"  class="wp-image-5577" title="wechat_2024 12 07_094047_352.png" alt="wechat_2024 12 07_094047_352.png" /><figcaption class="wp-element-caption">mysql数据库查询结果</figcaption></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1055" height="163" data-id="5576" src="https://img.hjyl.org/uploads/2024/12/wechat_2024-12-07_094155_048.png"  class="wp-image-5576" title="wechat_2024 12 07_094155_048.png" alt="wechat_2024 12 07_094155_048.png" /><figcaption class="wp-element-caption">导出来之后在文本编辑器下</figcaption></figure>
</figure>



<p>经过对比，可以看出在post_parent字段，就是显示图片插到哪篇文章ID下，如果显示为0，那说明只是在媒体库里，不在文章中显示，这样wp_get_attachment_image_src也就获取不了。</p>



<h3 class="wp-block-heading">修改数据库</h3>



<p>知道原因了就好修改了，一种方法是直接在phpmyadmin下用上面的查询代码找出来，一个个修改；一种可以用sql语句批量修改。但修改前，必须得备份数据库，数据无价。</p>



<p>sql语句：</p>



<pre class="wp-block-code"><code lang="sql" class="language-sql line-numbers">UPDATE `wp_posts` SET `post_parent` = '文章ID' WHERE `wp_posts`.`ID` BETWEEN 文章ID起始 AND 文章ID结束 AND `wp_posts`.`post_parent` = 0;</code></pre>



<h3 class="wp-block-heading">其他问题</h3>



<p>但是改了之后，相册是正常了，wp_get_attachment_image_src函数也能获取了，但是查看媒体库里的照片时，还是没有显示上传至哪篇文章下，如第一张图片。</p>



<p>另外在wp_postmeta表里找到相应的缩略图信息，可以用sql筛选一下：</p>



<pre class="wp-block-code"><code lang="sql" class="language-sql line-numbers"> SELECT * FROM  `wp_postmeta` WHERE meta_key IN ('_wp_attached_file', '_wp_attachment_backup_sizes',  '_wp_attachment_metadata',  '_thumbnail_id')</code></pre>



<p>貌似没找到相应的设置字段。知道的童鞋麻烦告知一下，不过到此问题是解决了，虽然不是很完美。通过sql修改数据，不是经常干，稳妥一些，切记一定要先备份数据库，切记！！！</p>



<p>参考文章：</p>



<p>①https://cloud.tencent.com/developer/information/mysql%E4%BF%AE%E6%94%B9%E5%AD%97%E6%AE%B5%E5%80%BC</p>



<p>②https://doc.weixiaoduo.com/wordpress/4468.html</p>
<div id="content-copyright"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;font-size: 13px;">版权声明: </span><span style="font-size: 13px;">本文采用 <a href="https://hjyl.org/go/aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzMuMC8=" rel="nofollow" target="_blank">BY-NC-SA</a> 协议进行授权，如无注明均为原创，转载请注明转自 <a href="https://hjyl.org">皇家元林</a><br>本文链接: <a rel="bookmark" title="wp_get_attachment_image_src获取不到文章附件？" href="https://hjyl.org/wp-get-attachment-image-src-get-photos/">wp_get_attachment_image_src获取不到文章附件？</a></span></div>]]></content:encoded>
					
					<wfw:commentRss>https://hjyl.org/wp-get-attachment-image-src-get-photos/feed/</wfw:commentRss>
			<slash:comments>24</slash:comments>
		
		
			</item>
		<item>
		<title>jQuery为每张图片链接自动加上class属性</title>
		<link>https://hjyl.org/jquery-add-class-pic/</link>
					<comments>https://hjyl.org/jquery-add-class-pic/#comments</comments>
		
		<dc:creator><![CDATA[皇家元林]]></dc:creator>
		<pubDate>Tue, 29 Mar 2011 06:08:02 +0000</pubDate>
				<category><![CDATA[元林手札]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[属性]]></category>
		<category><![CDATA[自动]]></category>
		<category><![CDATA[链接]]></category>
		<guid isPermaLink="false">http://hjyl.org/?p=1504</guid>

					<description><![CDATA[jQuery为每张图片链接自动加上class属性]]></description>
										<content:encoded><![CDATA[<p>先上码：</p>
<pre lang="language" line="1">
/* 用 jQuery 为每张图片链接自动加上 class="thickbox" */
$('#content p a').each(function(){ //根据主题内容区的 id 设置选择器
var a_href = $(this).attr('href').toLowerCase();
var file_type = a_href.substring(a_href.lastIndexOf('.'));
if (file_type == '.jpg' || file_type == '.png' || file_type == '.gif'){$(this).addClass('thickbox')};
});
</pre>
<p>这个再配合lightbox之类的图片展示代码用起来不错。<br />
此代码发现于ZWW-http://zww.me/archives/25196</p>
<p>还有一个<br />
[warning]<code>$('.entry a:has(img)').addClass("thickbox");</code>[/warning]</p>
<div id="content-copyright"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;font-size: 13px;">版权声明: </span><span style="font-size: 13px;">本文采用 <a href="https://hjyl.org/go/aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzMuMC8=" rel="nofollow" target="_blank">BY-NC-SA</a> 协议进行授权，如无注明均为原创，转载请注明转自 <a href="https://hjyl.org">皇家元林</a><br />本文链接: <a rel="bookmark" title="jQuery为每张图片链接自动加上class属性" href="https://hjyl.org/jquery-add-class-pic/">jQuery为每张图片链接自动加上class属性</a></span></div>
]]></content:encoded>
					
					<wfw:commentRss>https://hjyl.org/jquery-add-class-pic/feed/</wfw:commentRss>
			<slash:comments>11</slash:comments>
		
		
			</item>
		<item>
		<title>给朕的博客图片增加点效果</title>
		<link>https://hjyl.org/make-picture-better-effect/</link>
					<comments>https://hjyl.org/make-picture-better-effect/#comments</comments>
		
		<dc:creator><![CDATA[皇家元林]]></dc:creator>
		<pubDate>Thu, 08 Apr 2010 01:14:24 +0000</pubDate>
				<category><![CDATA[元林手札]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[博客]]></category>
		<category><![CDATA[图片]]></category>
		<guid isPermaLink="false">http://www.7lau.com/?p=884</guid>

					<description><![CDATA[利用jquery实现WordPress图片显隐特效]]></description>
										<content:encoded><![CDATA[<p>今天朕到处逛了一下，想给朕博客的图片添加一些效果，朕博客的图片都是外链flickr的，这点是为了防止搬家麻烦。看到一款插件叫<a href="https://hjyl.org/go/aHR0cDovL2Rvd25sb2Fkcy53b3JkcHJlc3Mub3JnL3BsdWdpbi9vdmVybGF5NHdwLnppcA==" rel="nofollow" target="_blank">Overlay4WP</a>，听说可以给图片一点效果，但是朕安装之后没一点反应，不知道怎么回事，难道需要上传到自己的空间才可以？<br />
然后就没管了。突然看到一篇文章<a href="https://hjyl.org/go/aHR0cDovL3d3dy53b3B1cy5vcmcvd29yZHByZXNzLWRlZXBpbi9kaXktdGhlbWVzLzIwNTMuaHRtbA==" rel="nofollow" target="_blank">《利用jquery实现图片显隐特效》</a>，是那只知更鸟写的，操作很简单，效果还不错。下面做个记号：<br />
演示：见本博客(把鼠标放在图片上试试)<br />
操作：1、首先需要在header.php中加载jquery，可以使用外链也可以内链。<br />
外链可以利用google为我们提供的JS库，据说可以提高js加载速度，格式如下：</p>
<pre lang="LANGUAGE" line="1"><script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.3.min.js"></script></pre>
<p>内链格式为：</p>
<pre lang="LANGUAGE" line="1"><script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.min.js" ></script></pre>
<p>然后再在header.php中添加：</p>
<pre lang="LANGUAGE" line="1"><script type="text/javascript">
$(function () {
$('img').hover(
function() {$(this).fadeTo("fast", 0.5);},
function() {$(this).fadeTo("fast", 1);
});
});
</script></pre>
<p>OK，你刷新下你的博客看看效果把。<br />
还有一种是鼠标悬停到图片上时，图片变得清晰。就是把后面的代码换成下面的即可：</p>
<pre lang="LANGUAGE" line="1">
    <script type="text/javascript">
    $(function() {
    $('img').animate({"opacity": .5 });

    $('img').hover(function() {
    $(this).stop().animate({ "opacity": 1 });
    }, function() {
    $(this).stop().animate({ "opacity": .5 });
    });
    });
    </script>
</pre>
<p>采用哪种图片显隐特效就看你喜好了，这一特效支持所有浏览器。</p>
<div id="content-copyright"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;font-size: 13px;">版权声明: </span><span style="font-size: 13px;">本文采用 <a href="https://hjyl.org/go/aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzMuMC8=" rel="nofollow" target="_blank">BY-NC-SA</a> 协议进行授权，如无注明均为原创，转载请注明转自 <a href="https://hjyl.org">皇家元林</a><br />本文链接: <a rel="bookmark" title="给朕的博客图片增加点效果" href="https://hjyl.org/make-picture-better-effect/">给朕的博客图片增加点效果</a></span></div>
]]></content:encoded>
					
					<wfw:commentRss>https://hjyl.org/make-picture-better-effect/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>一部巨作——名人堂</title>
		<link>https://hjyl.org/a-masterpiece-hall-of-fame/</link>
					<comments>https://hjyl.org/a-masterpiece-hall-of-fame/#respond</comments>
		
		<dc:creator><![CDATA[皇家元林]]></dc:creator>
		<pubDate>Tue, 26 Jan 2010 07:33:04 +0000</pubDate>
				<category><![CDATA[生活点滴]]></category>
		<category><![CDATA[名人堂]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[巨作]]></category>
		<guid isPermaLink="false">http://www.7lau.com/?p=672</guid>

					<description><![CDATA[一部巨作——名人堂，带有名字的和无名字的。]]></description>
										<content:encoded><![CDATA[<p>今天我同事发给我一张图片，是名人堂的所有人，哇塞，真是宏伟巨作啊！这上面你能认识几个人啊？看图:</p>
<p><figure style="width: 240px" class="wp-caption alignnone"><a href="https://hjyl.org/go/aHR0cDovL2Zhcm01LnN0YXRpYy5mbGlja3IuY29tLzQwMDkvNDMwNTMwNjg1N19iNjk3YmYxYzE2X2IuanBn" rel="nofollow" target="_blank"><img loading="lazy" decoding="async" title="名人堂" src="http://farm5.static.flickr.com/4009/4305306857_b697bf1c16_m.jpg" alt="名人堂" width="240" height="104" /></a><figcaption class="wp-caption-text">名人堂</figcaption></figure></p>
<p>点击放大。看下你能认识哪些人哦！下面一张图片是给这些人加上姓名的，所以你可以对照下看看，所谓的“名人”都有哪些呢？<span id="more-672"></span></p>
<p><figure style="width: 240px" class="wp-caption alignnone"><a href="https://hjyl.org/go/aHR0cDovL2Zhcm0zLnN0YXRpYy5mbGlja3IuY29tLzI3MDEvNDMwNjA2NTU5Ml8wZGI1ZjYzY2Q4X2IuanBn" rel="nofollow" target="_blank"><img loading="lazy" decoding="async" title="名人堂(附名字)" src="http://farm3.static.flickr.com/2701/4306065592_0db5f63cd8_m.jpg" alt="名人堂(附名字)" width="240" height="104" /></a><figcaption class="wp-caption-text">名人堂(附名字)</figcaption></figure></p>
<p>呵呵，怎么样？银才啊！这么一张图片就涵盖了这么多人。。。“嘿嘿，怎么名人堂好像还少一个人吧！”我说。一鸟人问:“谁啊？”。“我啊！呵呵”</p>
<div id="content-copyright"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;font-size: 13px;">版权声明: </span><span style="font-size: 13px;">本文采用 <a href="https://hjyl.org/go/aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzMuMC8=" rel="nofollow" target="_blank">BY-NC-SA</a> 协议进行授权，如无注明均为原创，转载请注明转自 <a href="https://hjyl.org">皇家元林</a><br />本文链接: <a rel="bookmark" title="一部巨作——名人堂" href="https://hjyl.org/a-masterpiece-hall-of-fame/">一部巨作——名人堂</a></span></div>
]]></content:encoded>
					
					<wfw:commentRss>https://hjyl.org/a-masterpiece-hall-of-fame/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>简单说下WordPress文章标题图片化</title>
		<link>https://hjyl.org/wordpress-title-photo-replaced/</link>
					<comments>https://hjyl.org/wordpress-title-photo-replaced/#comments</comments>
		
		<dc:creator><![CDATA[皇家元林]]></dc:creator>
		<pubDate>Thu, 05 Nov 2009 08:49:30 +0000</pubDate>
				<category><![CDATA[元林手札]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[代码]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[插件]]></category>
		<category><![CDATA[文章]]></category>
		<category><![CDATA[标题]]></category>
		<guid isPermaLink="false">http://localhost/wordpress/?p=206</guid>

					<description><![CDATA[我最近看到一个人的博客上面的所有标题都是图片，我觉得很诧异，很是喜欢。所以我就百度、Google了一下，才发现有专业一个插件。
首先，安装这样的一个插件。请大家看这里http://bbs.ylgod.cn/thread-5375-1-1.html。装插件很简单的，就不说了。
其次是怎么实现文章标题图片化呢？]]></description>
										<content:encoded><![CDATA[<p>我最近看到一个人的博客上面的所有标题都是图片，我觉得很诧异，很是喜欢。所以我就百度、Google了一下，才发现有专业一个插件。<br />
首先，安装这样的一个插件。请大家看这里<a href="https://hjyl.org/go/aHR0cDovL2Jicy55bGdvZC5jbi90aHJlYWQtNTM3NS0xLTEuaHRtbA==" rel="nofollow" target="_blank">http://bbs.ylgod.cn/thread-5375-1-1.html</a>。装插件很简单的，就不说了。<br />
其次是怎么实现文章标题图片化呢？<br />
（1）设置这个插件，安装激活后，在外观——&gt;TTF TITLES设置，英文的话默认就可以了，中文的需要先在font文件夹下上传一个中文字体，我用的是楷体，因为其他的太大上传不了。<br />
（2）修改源码：<br />
第一、如果修改博客标题的话。修改主题--&gt;修改header文件，将</p>
<pre lang="LANGUAGE" line="1"><?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></pre>
<p>修改为</p>
<pre lang="LANGUAGE" line="1"><?php echo get_settings('home'); ?>/"><?php the_ttftext(get_bloginfo('name'),true,your style name); ?></pre>
<p>第二、如果修改文章标题的话。修改---&gt;index、single、Page三个文件。找到&lt;h2&gt;&lt;/h2&gt;标签，将</p>
<pre lang="LANGUAGE" line="1"><?php the_title(); ?></pre>
<p>修改为</p>
<pre lang="LANGUAGE" line="1"><?php the_ttftext(get_the_title(), $echo = true, $overrides=""); ?></pre>
<p>其他像边栏部分等需要修改的话，听说是需要自己做图片的，这个我不知道怎么修改，有时间研究研究。如果有人知道，希望投稿给我，非常感谢你的支持！<br />
就到此先，有问题可以留言的！我第一时间回复你！<br />
相关资料：<a href="https://hjyl.org/go/aHR0cDovL2dlbGZsaW5nc2F0cGxheS5jb20vMjAwOC8wMy8yNi91c2luZy1qb2huLWxlYXZpdHRzcy10dGYtdGl0bGVzLXdvcmRwcmVzcy1wbHVnaW4v" rel="nofollow" target="_blank">http://gelflingsatplay.com/2008/03/26/using-john-leavittss-ttf-titles-wordpress-plugin/</a></p>
<div id="content-copyright"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;font-size: 13px;">版权声明: </span><span style="font-size: 13px;">本文采用 <a href="https://hjyl.org/go/aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzMuMC8=" rel="nofollow" target="_blank">BY-NC-SA</a> 协议进行授权，如无注明均为原创，转载请注明转自 <a href="https://hjyl.org">皇家元林</a><br />本文链接: <a rel="bookmark" title="简单说下WordPress文章标题图片化" href="https://hjyl.org/wordpress-title-photo-replaced/">简单说下WordPress文章标题图片化</a></span></div>
]]></content:encoded>
					
					<wfw:commentRss>https://hjyl.org/wordpress-title-photo-replaced/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
