diff --git a/app/Utilities/Formatter.php b/app/Utilities/Formatter.php index 0adee69..c936cd2 100644 --- a/app/Utilities/Formatter.php +++ b/app/Utilities/Formatter.php @@ -75,4 +75,21 @@ class Formatter return $url; } + + /** + * imgタグのsrcsetで使用できる形式で、プロフィール画像URLを生成します。 + * @param object $user Userなど、getProfileImageUrl()が実装されているオブジェクト + * @param int $baseSize 1x解像度における画像サイズ + * @param int $maxResolution 最大倍率 + * @return string srcset用の文字列 + */ + public function profileImageSrcSet($user, int $baseSize, int $maxResolution = 3) + { + $srcset = []; + for ($i = 1; $i <= $maxResolution; $i++) { + $srcset[] = $user->getProfileImageUrl($baseSize * $i) . " {$i}x"; + } + + return implode(',', $srcset); + } } diff --git a/resources/views/components/ejaculation.blade.php b/resources/views/components/ejaculation.blade.php index 9635273..3d17540 100644 --- a/resources/views/components/ejaculation.blade.php +++ b/resources/views/components/ejaculation.blade.php @@ -1,7 +1,7 @@