send pre-thumbnailed images when type is content-container
This commit is contained in:
@@ -51,6 +51,18 @@ class BlobEntriesController < ApplicationController
|
|||||||
file_ext = "gif"
|
file_ext = "gif"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# content-container may be pre-thumbnailed, see if the file is on the disk
|
||||||
|
if thumb == "content-container" && file_ext == "jpeg"
|
||||||
|
thumbnail_path =
|
||||||
|
Domain::PostFile::Thumbnail.absolute_file_path(
|
||||||
|
sha256,
|
||||||
|
"content_container",
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
send_file(thumbnail_path, type: "image/jpeg", disposition: "inline")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
width, height = thumb_params
|
width, height = thumb_params
|
||||||
filename = "thumb-#{sha256}-#{thumb}.#{file_ext}"
|
filename = "thumb-#{sha256}-#{thumb}.#{file_ext}"
|
||||||
cache_key = "vips:#{filename}"
|
cache_key = "vips:#{filename}"
|
||||||
|
|||||||
@@ -72,6 +72,15 @@ class Domain::PostFile::Thumbnail < ReduxApplicationRecord
|
|||||||
return nil unless (post_file = self.post_file)
|
return nil unless (post_file = self.post_file)
|
||||||
return nil unless (sha256 = post_file.sha256)
|
return nil unless (sha256 = post_file.sha256)
|
||||||
sha256_hex = HexUtil.bin2hex(sha256)
|
sha256_hex = HexUtil.bin2hex(sha256)
|
||||||
|
self.class.absolute_file_path(sha256_hex, thumb_type, T.must(self.frame))
|
||||||
|
end
|
||||||
|
|
||||||
|
sig do
|
||||||
|
params(sha256_hex: String, thumb_type: String, frame: Integer).returns(
|
||||||
|
T.nilable(String),
|
||||||
|
)
|
||||||
|
end
|
||||||
|
def self.absolute_file_path(sha256_hex, thumb_type, frame)
|
||||||
[
|
[
|
||||||
THUMB_ROOT_DIR,
|
THUMB_ROOT_DIR,
|
||||||
thumb_type.to_s,
|
thumb_type.to_s,
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
window.MiniProfiler.patchesApplied = true;
|
window.MiniProfiler.patchesApplied = true;
|
||||||
</script>
|
</script>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= favicon_link_tag "refurrer-logo-icon.png" %>
|
<link rel="icon" href="data:,">
|
||||||
|
<%= favicon_link_tag "refurrer-logo-icon.png", type: "image/png" %>
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
<%= csp_meta_tag %>
|
<%= csp_meta_tag %>
|
||||||
<%= javascript_pack_tag "application-bundle" %>
|
<%= javascript_pack_tag "application-bundle" %>
|
||||||
|
|||||||
Reference in New Issue
Block a user