Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/cms_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module CmsHelper
def cms_url(url)
if Rails.env.development?
return url if url.starts_with?("http")
return url if url.starts_with?("http") || url.starts_with?("/test-images")
"#{Rails.application.config.strapi_image_url}#{url}"
else
url
Expand Down
29 changes: 22 additions & 7 deletions app/services/cms/providers/strapi/mocks/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@ module Providers
module Strapi
module Mocks
class Image
include ActionView::Helpers::AssetUrlHelper

SIZES = {
medium: [750, 500],
small: [500, 300],
thumbnail: [250, 100]
large: {
size: [1000, 800],
url: "/test-images/large_test.png"
},
medium: {
size: [750, 500],
url: "/test-images/medium_test.png"
},
small: {
size: [500, 300],
url: "/test-images/small_test.png"
},
thumbnail: {
size: [250, 100],
url: "/test-images/thumbail_test.png"
}
}

def self.as_model(caption: nil)
Expand Down Expand Up @@ -40,20 +55,20 @@ def self.generate_data(caption: nil)
ext: ".png",
mime: "image/png",
size: 137.23,
url: Faker::LoremFlickr.image(size: "1000x800")
url: SIZES[:large][:url]
}
end

def self.format(name, hash_name, size)
{
ext: ".png",
url: Faker::LoremFlickr.image(size: SIZES[size].join("x")),
url: SIZES[size][:url],
hash: hash_name,
mime: "image/png",
name: name,
size: 390.03,
width: SIZES[size][0],
height: SIZES[size][1],
width: SIZES[size][:size][0],
height: SIZES[size][:size][1],
sizeInBytes: 390028
}
end
Expand Down
Binary file added public/test-images/large_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/test-images/medium_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/test-images/small_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/test-images/thumbnail_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.