change code to take new filenames
This commit is contained in:
parent
f7147f79e2
commit
fc2c390fd1
@ -7,7 +7,7 @@ module Merged
|
||||
def bg(section , clazz = "")
|
||||
attributes = {class: clazz}
|
||||
return attributes if section.image.blank?
|
||||
img = asset_url( section.image.assert_name )
|
||||
img = asset_url( section.image.asset_name )
|
||||
attributes["style"] = "background-image: url('#{img}');"
|
||||
if(section.option("fixed") == "on")
|
||||
attributes[:class] = attributes[:class] + " bg-fixed"
|
||||
@ -18,7 +18,8 @@ module Merged
|
||||
# works for with sections and cards that respond to .image
|
||||
def image_for(element , classes = "")
|
||||
return "" if element.image.blank?
|
||||
image_tag(element.image.assert_name , class: classes)
|
||||
image = element.image
|
||||
image_tag(image.asset_name , alt: image.name , class: classes )
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -70,15 +70,11 @@ module Merged
|
||||
Image.reload
|
||||
end
|
||||
|
||||
def assert_name
|
||||
image_root + "/" + self.name
|
||||
def asset_name
|
||||
image_root + "/" + self.id.to_s
|
||||
end
|
||||
|
||||
def filename_old
|
||||
full_filename = self.name + "." + self.type
|
||||
Rails.root.join(asset_root, full_filename)
|
||||
end
|
||||
def filename_new
|
||||
def full_filename
|
||||
full_filename = self.id.to_s + "." + self.type
|
||||
Rails.root.join(asset_root, full_filename)
|
||||
end
|
||||
|
@ -31,7 +31,7 @@
|
||||
-if( card.image.blank? )
|
||||
%p No image
|
||||
-else
|
||||
= image_tag( card.image.assert_name , class: "p-3")
|
||||
= image_for( card, "p-3")
|
||||
.basis-72.grow
|
||||
%h3.mt-4.text-lg.font-bold Fields
|
||||
= form_tag( card_url(card.id) , {method: :patch , class: "mx-auto mt-8 mb-0 max-w space-y-4" } ) do
|
||||
|
@ -15,7 +15,7 @@
|
||||
%strong.inline-block.rounded.bg-yellow-200.px-3.py-1.text-md.font-medium
|
||||
= aspect_ratio(image)
|
||||
.w-full.object-contain.h-72
|
||||
=image_tag(image.assert_name)
|
||||
=image_tag(image.asset_name)
|
||||
.flex.justify-between.mb-8
|
||||
%strong.inline-block.rounded.bg-orange-50.px-3.py-1.text-md.font-medium
|
||||
= "#{image.size}k"
|
||||
|
@ -44,7 +44,7 @@
|
||||
= link_to(section_select_image_url(section.id)) do
|
||||
%h3.mt-4.text-lg.font-bold Image
|
||||
-if section.image
|
||||
= image_tag( section.image.assert_name , class: "h-40")
|
||||
= image_for( section , "h-40")
|
||||
-else
|
||||
%p No image
|
||||
.basis-52.grow
|
||||
|
@ -18,7 +18,7 @@
|
||||
-if( @section.image.blank? )
|
||||
%p No image
|
||||
-else
|
||||
= image_tag( @section.image.assert_name , class: "my-3")
|
||||
= image_for( @section , "my-3")
|
||||
= yellow_button("Change Image", section_select_image_url(@section.id))
|
||||
= red_button( "Remove image", section_set_image_path( @section.id , image: ""))
|
||||
|
||||
|
@ -5,20 +5,20 @@ module Merged
|
||||
let(:first) {Image.first}
|
||||
|
||||
it "has Image.all" do
|
||||
expect(Image.all.length).to be 41
|
||||
expect(Image.all.length).to be 17
|
||||
end
|
||||
it "has image" do
|
||||
expect(first.class).to be Image
|
||||
end
|
||||
it "has name" do
|
||||
expect(first.name).to eq "3dprinter_wide"
|
||||
expect(first.name).to eq "common_spaces"
|
||||
end
|
||||
it "has height and width" do
|
||||
expect(first.height).to eq 457
|
||||
expect(first.width).to eq 1279
|
||||
expect(first.height).to eq 300
|
||||
expect(first.width).to eq 560
|
||||
end
|
||||
it "has height and width" do
|
||||
# expect(first.aspect_ratio).to eq [13,5]
|
||||
expect(first.aspect_ratio).to eq [13,7]
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user