Nikita
Nikita

Reputation: 155

How do I display an image from an attachment?

I'd like to display an image, that I uploaded with CarrierWave, in the following code block. And ow can I define the image size?

  <%= simple_format(@employer.name) %>
   <% if @employer.attachment.present? %>
          <h4>Attachment</h4>
          <div class="attachment">
            <p>
              <%= link_to File.basename(@employer.attachment.url),
                @employer.attachment.url %>
             (<%= number_to_human_size(@employer.attachment.size) %>)
</p> </div>
<% end %>

Upvotes: 2

Views: 486

Answers (2)

Slava.K
Slava.K

Reputation: 3080

Use image_tag:

<%= image_tag(@employer.attachment.url) %>

To define custom image size add version to your uploader. See documentation on adding versions

Upvotes: 2

Jasmin Skopljak
Jasmin Skopljak

Reputation: 19

As @Slava.K said use image_tag. To change image size you can use Imagemagick and MiniMagick, and define image sizes in uploader

See documentation for CarrierWave: http://www.rubydoc.info/gems/carrierwave/

Upvotes: 1

Related Questions