我用Jquery PrettyPhoto做了一个幻灯片放映,但是它不允许用户下载图片。有人知道我如何添加一个链接,这样用户就可以下载图片了吗?
下面是我的代码:(我在Yii中使用prettyPhoto小部件,但是任何关于prettyPhoto的一般答案都会很棒)
<?php
$this->beginWidget('ext.prettyPhoto.PrettyPhoto', array(
'id'=>'pretty_photo',
// prettyPhoto options
'options'=>array(
'opacity'=>0.60,
'modal'=>true,
),
));
?>
<div class="column4-front image-gallery">
<a href="/files/show/<?php echo $data->image; ?>" rel="prettyPhoto[pp_gal]" title="<?php echo $data->caption; ?>">
<img src="/files/show/thumb/<?php echo $data->image; ?>" />
</a>
</div>
<?php $this->endWidget('widgets.prettyPhoto');?>
6条答案
按热度按时间cwtwac6a1#
此解决方案不需要更改PrettyPhoto JS。
我使用回调函数来搜索包含大图像的元素,并添加一个链接到图像的新元素(仅适用于HTML5):
还有另一个(无HTML5)解决方案,更改为:
由
您需要一个“download.php”来强制下载img,例如:https://stackoverflow.com/a/7238099/2369084
fbcarpbf2#
别紧张!
HTML**(标题为空!)**
JS(在文档内部准备)
不需要对PrettyPhoto JS做任何修改。这是一个简单的想法。你可以在Yii框架中玩。
更简单:仅限JS(在视图中包含JS)
13z8s7eq3#
这是我的解决方案(不适用于Yii)-http://loco.ru/materials/343-wordpress-nextgen-gallery-dobavit-ssylku-sohranit-foto添加链接打开原始图像。
des4xlb04#
我想现在已经很晚了但这对某些人有帮助
首先,开始使用最新版本,并有jquery 1.4+至少原因不是2.0是准备好了,我们都最好开始移动lol。
好的,我将采用上面的例子
不要执行link=“ur link”,而是使用如下所示的数据属性
这是第一步,改变你的格式有点。
现在打开你的prettyphoto.js
发现
它将与开头的所有标记一起出现。
现在将其编辑如下
下一步查找此部分
围绕线204
替换为
如上面2行所述,您可以将.“your_class”替换为您想要的任何名称,然后转到“转到页面”
和所有完成刷新你的页面,即F5的原因,这是在文件中更改.....和加载,它会工作得很好。
为大家干杯。
tpxzln5u5#
好了,我解决了我的问题,here是我找到的一个例子。他们添加了下载照片的链接,如下所示:
需要对jquery.prettyphoto.js文件做一些修改。我使用的是v 3.1.2,可以下载here
这是我在前面提到的before示例中所做的更改
如果你想在yii中的prettyphoto extention中使用它,你可以把javaScript文件替换成你修改过的文件,然后:
并将其添加到相关控制器中,对于我来说,CompaniaController:
hmmo2u0o6#
我通过编辑img_markup属性中的prettyPhoto.js文件解决了这个问题。
更改此项
到这