Commit 38899124 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix: rewrite regenerate image function to use saveSizes method from Image entity

parent 24136613
Pipeline #1197 passed with stages
in 8 minutes and 15 seconds
......@@ -82,7 +82,7 @@ class Image extends BaseMedia
$this->deleteSizes();
}
private function saveSizes(): void
public function saveSizes(): void
{
// save derived sizes
$imageService = service('image');
......
......@@ -110,7 +110,10 @@ class SettingsController extends BaseController
$allPodcasts = (new PodcastModel())->findAll();
foreach ($allPodcasts as $podcast) {
$podcastImages = glob(ROOTPATH . "public/media/podcasts/{$podcast->handle}/*_*");
$podcastImages = glob(
ROOTPATH . 'public/' . config('App')->mediaRoot . "/podcasts/{$podcast->handle}/*_*{jpg,png,webp}",
GLOB_BRACE
);
if ($podcastImages) {
foreach ($podcastImages as $podcastImage) {
......@@ -119,19 +122,22 @@ class SettingsController extends BaseController
}
}
}
$podcast->setCover($podcast->cover);
if ($podcast->banner_path !== null) {
$podcast->setBanner($podcast->banner);
$podcast->cover->saveSizes();
if ($podcast->banner_id !== null) {
$podcast->banner->saveSizes();
}
foreach ($podcast->episodes as $episode) {
if ($episode->cover_path !== null) {
$episode->setCover($episode->cover);
if ($episode->cover_id !== null) {
$episode->cover->saveSizes();
}
}
}
$personsImages = glob(ROOTPATH . 'public/media/persons/*_*');
$personsImages = glob(
ROOTPATH . 'public/' . config('App')->mediaRoot . '/persons/*_*{jpg,png,webp}',
GLOB_BRACE
);
if ($personsImages) {
foreach ($personsImages as $personsImage) {
if (is_file($personsImage)) {
......@@ -142,8 +148,8 @@ class SettingsController extends BaseController
$persons = (new PersonModel())->findAll();
foreach ($persons as $person) {
if ($person->avatar_path !== null) {
$person->setAvatar($person->avatar);
if ($person->avatar_id !== null) {
$person->avatar->saveSizes();
}
}
......
......@@ -40,7 +40,7 @@
<?= location_link($podcast->location, 'text-xs font-semibold p-2') ?>
<?php endif; ?>
</div>
<div class="mt-4">
<div class="mt-6">
<h2 class="text-xs font-bold tracking-wider text-gray-600 uppercase border-b-2 border-subtle font-display"><?= lang('Podcast.stats.title') ?></h2>
<div class="flex flex-col text-sm">
<?php foreach ($stats as $key => $value): ?>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment