attachinary
attachinary copied to clipboard
Dimensions for Remove thumbnail
Is there a way to specify the dimensions of the Thumbnail for the Remove action when using the f.attachinary_file_field form helper?
It's set to thumbnail size of 75x75. Wondering if I can configure those dimensions when it's generated by the helper.
Thanks.
Awesome gem - just dumped loads of my code doing the same thing with PaperClip :-)
You can pass in a custom template when you initialize the input field. Here is a coffeescript example where I use a custom transformation. See https://github.com/assembler/attachinary/blob/master/lib/assets/javascripts/attachinary.js.coffee
$(".attachinary-input").attachinary(
template: """
<ul>
<% for(var i=0; i<files.length; i++){ %>
<li>
<% if(files[i].resource_type == "raw") { %>
<div class="raw-file"></div>
<% } else { %>
<img
src="<%= $.cloudinary.url(files[i].public_id, { "version": files[i].version, "format": 'jpg', "transformation": 'my_custom_transformation' }) %>"
alt="" width="320" height="320" />
<% } %>
<a href="#" data-remove="<%= files[i].public_id %>">Remove</a>
</li>
<% } %>
</ul>
"""
)