gpt4 book ai didi

javascript - 取出图片标签 alt :missing. "image tag without an alt id is prefered and not showing missing"

转载 作者:行者123 更新时间:2023-11-28 06:03:17 27 4
gpt4 key购买 nike

我想删除图像标签正在寻找的缺失错误。我不想要 ult 标签占位符,试图故意将其保留为空白,直到我使用回形针浏览上传照片。

我已经将 url(:missing) 更改为许多其他内容,例如 nil 等。是否还有我可以使用的另一个关键字。当我运行代码时,在浏览图像之前,它会在图像位置处缺失一个位置。加载图像没有问题,只是之前它只是妨碍并且看起来不太好!谢谢!!

application_helper.rb:

def form_image_select(post)  
return image_tag post.image.url(:missing),
id: 'image-preview',
class: 'img-responsive'

end

我的 post.js 为我提供了预览!

var loadFile = function(event) {  
var output = document.getElementById('image-preview');
output.src = URL.createObjectURL(event.target.files[0]);
};

这是我在 post.html 中发布的位置:

<div class="image-wrap">
<%= form_image_select(@post) %>
</div>

最佳答案

图像上 alt 属性所需的语法就是 image_tag 上的 alt 关键字:

return image_tag post.image.url,
id: 'image-preview',
class: 'img-responsive',
alt: 'missing'

关于javascript - 取出图片标签 alt :missing. "image tag without an alt id is prefered and not showing missing",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37101242/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com