取出图像标签alt:丢失"没有alt-id的图像标签是优选的并且不显示丢失的“;

Take out image tag alt:missing. "image tag without an alt id is prefered and not showing missing"

本文关键字:标签 图像 显示 alt-id alt 丢失 没有 quot      更新时间:2023-09-26

我想去掉image标签正在查找的丢失错误。我不想要ult标签占位符,在我使用回形针上传浏览照片之前,我会故意将其留空。

我已经把url(:missing)改成了很多其他的东西,比如nil等等。还有其他关键词我可以用吗。当我运行代码时,在我浏览图像之前,它会在图像位置的某个位置给我一个缺失。加载图像没有问题,就在它挡住去路之前,看起来不太好!谢谢

application_help.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'