简体   繁体   English

带有回形针的降价促销中的image_tag

[英]image_tag in markdown with paperclip

I'm adding images in the text of my blog articles. 我在博客文章的文本中添加了图像。

I have the BlogImage model: 我有BlogImage模型:

class BlogImage < ActiveRecord::Base
  attr_accessible :blog_id, :caption, :image

  belongs_to :blog

  has_attached_file :image, styles: { big: "1200X630>", medium: "300x300>", thumb: "300x300>" }, default_url: "/images/:style/missing.png"

  validates_attachment_presence :image
  validates_attachment_size :image, :less_than => 3.megabytes
  validates_attachment_content_type :image, :content_type => ['image/jpeg', 'image/png']
end

and my article body is rendered with: 并且我的文章正文呈现为:

    :markdown
      #{blog.body}

The markdown is handled by the gem rdiscount 减价由gem rdiscount处理

I would like to be able to write a tag in my markdown, (such as [image_name] or similar) so that this would be automatically converted upon rendering with the right image tag. 我希望能够在我的markdown中写一个标签(例如[image_name]或类似标签),以便在使用正确的图像标签渲染时可以自动将其转换。

I don't know where to start with. 我不知道从哪里开始。

Thanks. 谢谢。

You can insert an image with RDiscount using syntax like: 您可以使用以下语法使用RDiscount插入图像:

![GitHub Favicon](https://github.com/favicon.ico =16x16)

The title is required (but can be empty). 标题为必填项(但可以为空)。 The size is optional. 大小是可选的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM