5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-03 23:25:46 +00:00

poder subir varias imagenes

This commit is contained in:
f 2018-07-20 13:34:33 -03:00
parent ba37ffbe90
commit 21aedce0ea
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
3 changed files with 15 additions and 5 deletions

View file

@ -205,8 +205,15 @@ class Post
if t.image?
begin
i = Post::ImageUploader.new(site)
i.store! v.tempfile
v = i.url
if t.multiple?
v = v.map do |tmp|
i.store! tmp.tempfile
i.url
end
else
i.store! v.tempfile
v = i.url
end
rescue CarrierWave::IntegrityError => e
v = e.message
end
@ -234,7 +241,7 @@ class Post
template_fields.each do |tf|
# TODO descubrir de mejor forma que el archivo no es del formato
# correcto
if tf.image? && get_front_matter(tf.key).split('/').to_a.count <= 1
if tf.image? && [get_front_matter(tf.key)].flatten.map { |i| i.split('/').to_a.count <= 1 }.any?
add_error validate: get_front_matter(tf.key)
end
end

View file

@ -131,7 +131,7 @@ class Post
end
def image?
value == 'image'
array? ? value.first == 'image' : value == 'image'
end
# Si la plantilla es simple no está admitiendo Hashes como valores

View file

@ -1,5 +1,8 @@
- if @post.url? name
%img.img-fluid{src: @site.get_url_for_sutty(@post.get_front_matter(name))}
- name = [name,''] if template.multiple?
= file_field_tag field_name_for_post_as_string(name),
class: 'form-control',
required: template.required?
required: template.required?,
multiple: template.multiple?,
accept: 'image/*'