diff --git a/app/models/article.rb b/app/models/article.rb index f662c38dc45..1585895971b 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -37,9 +37,9 @@ class Article < ApplicationRecord paginates_per 24 acts_as_taggable - def prepared_thumbnail_url + def prepared_thumbnail_url(thumbnail_size = THUMBNAIL_SIZE) if thumbnail.attached? - thumbnail.variant(resize_to_limit: THUMBNAIL_SIZE).processed.url + thumbnail.variant(resize_to_limit: thumbnail_size).processed.url else image_url('/ogp/blank.svg') end diff --git a/app/views/articles/_recent_articles.html.slim b/app/views/articles/_recent_articles.html.slim index 43249315827..6fb1bebe794 100644 --- a/app/views/articles/_recent_articles.html.slim +++ b/app/views/articles/_recent_articles.html.slim @@ -10,12 +10,14 @@ = link_to recent_article, class: 'card-list-item__inner' do .card-list-item__thumbnail .card-list-item__thumbnail-inner - - if recent_article.thumbnail.attached? - = image_tag recent_article.thumbnail.variant(resize_to_limit: [200, 105]).processed.url, \ + - if recent_article.prepared_thumbnail? + = image_tag recent_article.prepared_thumbnail_url([200, 105]), \ class: 'card-list-item__thumbnail-image', \ alt: "ブログ記事「#{recent_article.title}」のアイキャッチ画像" - else - = image_tag 'work-blank.svg', class: 'card-list-item__thumbnail-image', alt: 'ブログ記事のブランクアイキャッチ画像' + = image_tag recent_article.selected_thumbnail_url, \ + class: 'card-list-item__thumbnail-image', \ + alt: "ブログ記事「#{recent_article.title}」のアイキャッチ画像" .card-list-item__rows .card-list-item__row .card-list-item-title