mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 04:11:41 +00:00
poder subir varias imagenes
This commit is contained in:
parent
ba37ffbe90
commit
21aedce0ea
3 changed files with 15 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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/*'
|
||||
|
|
Loading…
Reference in a new issue