Skip to content

Commit

Permalink
proxy for cover image post
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed Oct 19, 2023
1 parent edee15c commit 7ec045c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def show
# url: Routes.articles_show_url(socket, :show, post.id),
title: "#{@post.title} on Rauversion",
description: "Read #{@post.title} by #{@post.user.username} on Rauversion.",
image: @post&.cover_url(:small),
image: @post&.cover_url(:medium),
)
end

Expand Down
12 changes: 6 additions & 6 deletions app/models/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ class Post < ApplicationRecord
def cover_url(size = nil)
url = case size
when :medium
cover.variant(resize_to_limit: [200, 200])&.processed&.url

Rails.application.routes.url_helpers.rails_storage_proxy_url cover.variant(resize_to_limit: [200, 200])
when :large
cover.variant(resize_to_limit: [500, 500])&.processed&.url
Rails.application.routes.url_helpers.rails_storage_proxy_url cover.variant(resize_to_limit: [500, 500])

when :small
cover.variant(resize_to_limit: [50, 50])&.processed&.url
Rails.application.routes.url_helpers.rails_storage_proxy_url cover.variant(resize_to_limit: [50, 50])

when :horizontal
cover.variant(resize_to_limit: [600, 300])&.processed&.url
Rails.application.routes.url_helpers.rails_storage_proxy_url cover.variant(resize_to_limit: [600, 300])
else
cover.variant(resize_to_limit: [200, 200])&.processed&.url
Rails.application.routes.url_helpers.rails_storage_proxy_url cover.variant(resize_to_limit: [200, 200])
end

url || "daniel-schludi-mbGxz7pt0jM-unsplash-sqr-s-bn.png"
Expand Down

0 comments on commit 7ec045c

Please sign in to comment.