希望现在回答你的问题还不算晚,但我最近不得不修改漂亮的照片代码来做你所要求的。
有一行从锚的“标题”属性设置描述。您可以更改它以从任何您想要的地方获取描述。我决定在存储描述的锚点下创建一个 <p> 标记。
要更改描述的来源,您必须修改漂亮的照片源。找到如下所示的行:
pp_descriptions = (isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr('rel').indexOf(theRel) != -1) return ($(n).attr('title')) ? $(n).attr('title') : ""; }) : $.makeArray($(this).attr('title'));
它应该在第 152 行,至少从 3.1.3 版开始。只需使用查找和替换工具来搜索“pp_descriptions”。
将其更改为:
pp_descriptions = (isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr('rel').indexOf(theRel) != -1) return ($(n).find('p').text()) ? $(n).find('p').text() : ""; }) : $.makeArray($(this).find('p').text());
将“(this).attr('title')”更改为“.find('p').text()”将在锚中定位一个<p>标签,而不是使用“title”属性。您可能想用 CSS 隐藏 <p> 标记,这样它就不会显示在您的网站上。
现在 html 标记应如下所示:
<a href="path/to/your/big-image.jpg" rel="prettyPhoto">
<p>This is the Description</p>
<img src="path/to/your/small-image.jpg" alt="caption text" />
</a>