From c490258e11d9fb77aa1bf52e57f2c47731410ab3 Mon Sep 17 00:00:00 2001 From: Kuroneko Date: Sun, 26 May 2024 13:50:42 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=96=E3=83=AD=E3=82=B0=E3=81=AE=E3=82=B5?= =?UTF-8?q?=E3=83=A0=E3=83=8D=E3=82=A4=E3=83=AB=E3=81=8C=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E8=A8=98=E4=BA=8B=E3=81=AB=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/article.rb | 4 ++-- app/views/articles/_recent_articles.html.slim | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) 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