From 9fd73d0c38573312b5136d61edd2d4bbbdd76e18 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 20 Jul 2018 15:17:34 -0300 Subject: [PATCH] mostrar todas las imagenes --- app/models/post.rb | 6 ++++-- app/views/posts/template_field/_image.haml | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index c9b31e9a..9e37283a 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -262,9 +262,11 @@ class Post # Detecta si un valor es un archivo def url?(name) path = get_front_matter(name) - return false unless path.is_a? String + return false unless path.is_a?(String) || path.is_a?(Array) # El primer valor es '' porque la URL empieza con / - path.split('/').second == 'public' + [path].flatten.map do |p| + p.split('/').second == 'public' + end.all? end def image?(name) diff --git a/app/views/posts/template_field/_image.haml b/app/views/posts/template_field/_image.haml index 1ef95b12..9ab2a2af 100644 --- a/app/views/posts/template_field/_image.haml +++ b/app/views/posts/template_field/_image.haml @@ -1,5 +1,8 @@ - if @post.url? name - %img.img-fluid{src: @site.get_url_for_sutty(@post.get_front_matter(name))} + .row + - [@post.get_front_matter(name)].flatten.each do |url| + .col + %img.img-fluid{src: @site.get_url_for_sutty(url)} - name = [name,''] if template.multiple? = file_field_tag field_name_for_post_as_string(name), class: 'form-control',