脚本标记中的Paperclip图像集显示的是图像文本url,而不是图像-expandablebanners.js
Paperclip image set within script tags shows the image text url not the image - expandablebanners.js
我在rails网站上使用expandablebanners.js,显示滚动图像的代码是;
<script type="text/javascript">
var roll_img = "<%= @advert.roll_img.url %>"
var squarecenterbottom = ExpandableBanners.banner("squarecenterbottom", roll_img);
squarecenterbottom.animated = true;
squarecenterbottom.setDirection('down', 'center');
squarecenterbottom.expandOnClick = false;
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded",function(){documentReady=true;});}
else if (!window.onload) window.onload = function(){documentReady=true;}
</script>
主图像就这样显示在页面上;
<%= link_to image_tag(@advert.img(:horizontal) title: @advert.name,),
@advert.target_url, :id => 'squarecenterbottom' %>
当您滚动主图像时,它应该显示滚动图像,但是当我滚动图像时,它只显示滚动图像的url(即文本(,我不知道问题是什么…
代码输出为;
<script type="text/javascript">
var roll_img = "http://localhost:3000/system/adverts/large_imgs/000/000/004/original/1n.jpg?1401967781"
var squarecenterbottom = ExpandableBanners.banner("squarecenterbottom", roll_img );
squarecenterbottom.animated = true;
squarecenterbottom.setDirection('down', 'center');
squarecenterbottom.expandOnClick = false;
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded",function(){documentReady=true;});}
else if (!window.onload) window.onload = function(){documentReady=true;}
</script>
<a href="www.example.com id="squarecenterbottom"><img alt="test22" height="90" src="/system/adverts/imgs/000/000/004/horizontal/2n.jpeg?1401818651" title="test22" width="730" /></a>
</div>
这是文档中的代码,展示了它的工作原理;
<script type="text/javascript">
var squaretopleft = ExpandableBanners.banner("squaretopleft", "images/square_expanded.jpg");
squaretopleft.setCloseImage("images/closebutton.jpg", 'left', 'top');
squaretopleft.animated = true;
squaretopleft.setDirection('up', 'left');
squaretopleft.expandOnClick = false;
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded",function(){documentReady=true;});}
else if (!window.onload) window.onload = function(){documentReady=true;}
</script>
</head>
<body>
<a id="squaretopleft" href="www.yourwebsite.com"><img src="images/square.jpg" /></a>
</body>
</html>
这可能是路径或HTML结构问题
检查事项:
- 在输出中,
<a>
元素紧跟在<script>
之后。然后是</div>
结束标记。你有空的<div>
吗?他们都在<body>
吗 - 由于
ExpandableBanners
代码设置了onload
和DOMContentLoaded
侦听器,请尝试将其移动到文档的<head>
中 - 您的原始图像的扩展名为.jpeg,滚动图像的扩展号为.jpg。这没什么问题,但请确保在正确的路径中有正确的图像(和扩展名(。例如,原始图像在
/imgs
文件夹下,而滚动在/large_imgs
下。这样可以吗 - 尝试滚动图像的相对路径。在这种情况下:从一开始就删除
http://localhost:3000
。(假设您的原始图像显示正常。(
几点:
var roll_img...
声明末尾缺少分号- 正如Ruby Racer所提到的,生成的锚标记缺少双引号
<a href="www.example.com
相关文章:
- 使用带括号的图像URL作为jQuery的背景
- 可以't使用PHP使用Froala编辑器上传图像URL
- 语义ui表单验证:图像url
- 使用javascript从HTML网页中提取图像url
- 检测图像URL是否已损坏JQUERY
- Imgur|检索给定相册链接的直接图像URL
- 使用现有代码更改基于浏览器宽度的图像url
- 在按钮单击时将图像URL数据显示到弹出框中,而无需禁用背景
- 从图像URL javascript html保存图像文件
- jQuery获取不带引号的背景图像URL
- 如何从Node中的图像url将图像上传到谷歌云存储
- Genearate Cloudinary图像url,而不使用libs
- 正在尝试在SVG标记中显示图像URL
- Angular 2-检查图像url是否有效或已损坏
- 将跨度内容(图像url)转换为图像(显示)
- 使用JavaScript正则表达式从html srcset获取图像url
- 如何在谷歌图像搜索api v2中获取图像url
- Parse.com-在JavaScript SDK中模板化集合时检索图像URL
- 在Symfony中,我如何在javascript中编写图像url
- 将背景图像URL与正则表达式匹配