mirror of
https://code.castopod.org/adaures/castopod
synced 2025-06-05 17:02:01 +00:00
fix(housekeeping): replace the use of GLOB_BRACE with looping over file extensions
The GLOB_BRACE flag is not available on non GNU systems, such as Solaris or Alpine Linux. fixes #154
This commit is contained in:
parent
f21ca57603
commit
42d92d0c8d
@ -116,17 +116,21 @@ class SettingsController extends BaseController
|
|||||||
helper('media');
|
helper('media');
|
||||||
|
|
||||||
$allPodcasts = (new PodcastModel())->findAll();
|
$allPodcasts = (new PodcastModel())->findAll();
|
||||||
|
$imageExt = ['jpg', 'png', 'webp'];
|
||||||
|
|
||||||
foreach ($allPodcasts as $podcast) {
|
foreach ($allPodcasts as $podcast) {
|
||||||
$podcastImages = glob(media_path("/podcasts/{$podcast->handle}/*_*{jpg,png,webp}"), GLOB_BRACE);
|
foreach ($imageExt as $ext) {
|
||||||
|
$podcastImages = glob(media_path("/podcasts/{$podcast->handle}/*_*{$ext}"));
|
||||||
|
|
||||||
if ($podcastImages) {
|
if ($podcastImages) {
|
||||||
foreach ($podcastImages as $podcastImage) {
|
foreach ($podcastImages as $podcastImage) {
|
||||||
if (is_file($podcastImage)) {
|
if (is_file($podcastImage)) {
|
||||||
unlink($podcastImage);
|
unlink($podcastImage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$podcast->cover->saveSizes();
|
$podcast->cover->saveSizes();
|
||||||
if ($podcast->banner_id !== null) {
|
if ($podcast->banner_id !== null) {
|
||||||
$podcast->banner->saveSizes();
|
$podcast->banner->saveSizes();
|
||||||
@ -139,11 +143,13 @@ class SettingsController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$personsImages = glob(media_path('/persons/*_*{jpg,png,webp}'), GLOB_BRACE);
|
foreach ($imageExt as $ext) {
|
||||||
if ($personsImages) {
|
$personsImages = glob(media_path("/persons/*_*{$ext}"));
|
||||||
foreach ($personsImages as $personsImage) {
|
if ($personsImages) {
|
||||||
if (is_file($personsImage)) {
|
foreach ($personsImages as $personsImage) {
|
||||||
unlink($personsImage);
|
if (is_file($personsImage)) {
|
||||||
|
unlink($personsImage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,27 +182,31 @@ class SettingsController extends BaseController
|
|||||||
helper('media');
|
helper('media');
|
||||||
|
|
||||||
if ($this->request->getPost('rewrite_media') === 'yes') {
|
if ($this->request->getPost('rewrite_media') === 'yes') {
|
||||||
|
$imageExt = ['jpg', 'png', 'webp'];
|
||||||
// Delete all podcast image sizes to recreate them
|
// Delete all podcast image sizes to recreate them
|
||||||
$allPodcasts = (new PodcastModel())->findAll();
|
$allPodcasts = (new PodcastModel())->findAll();
|
||||||
foreach ($allPodcasts as $podcast) {
|
foreach ($allPodcasts as $podcast) {
|
||||||
$podcastImages = glob(media_path("/podcasts/{$podcast->handle}/*_*{jpg,png,webp}"), GLOB_BRACE);
|
foreach ($imageExt as $ext) {
|
||||||
|
$podcastImages = glob(media_path("/podcasts/{$podcast->handle}/*_*{$ext}"));
|
||||||
|
|
||||||
if ($podcastImages) {
|
if ($podcastImages) {
|
||||||
foreach ($podcastImages as $podcastImage) {
|
foreach ($podcastImages as $podcastImage) {
|
||||||
if (is_file($podcastImage)) {
|
if (is_file($podcastImage)) {
|
||||||
unlink($podcastImage);
|
unlink($podcastImage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete all person image sizes to recreate them
|
// Delete all person image sizes to recreate them
|
||||||
$personsImages = glob(media_path('/persons/*_*{jpg,png,webp}'), GLOB_BRACE);
|
foreach ($imageExt as $ext) {
|
||||||
if ($personsImages) {
|
$personsImages = glob(media_path("/persons/*_*{$ext}"));
|
||||||
foreach ($personsImages as $personsImage) {
|
if ($personsImages) {
|
||||||
if (is_file($personsImage)) {
|
foreach ($personsImages as $personsImage) {
|
||||||
unlink($personsImage);
|
if (is_file($personsImage)) {
|
||||||
|
unlink($personsImage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,7 +217,7 @@ class SettingsController extends BaseController
|
|||||||
if (str_ends_with($image->file_path, 'banner.jpg') || str_ends_with(
|
if (str_ends_with($image->file_path, 'banner.jpg') || str_ends_with(
|
||||||
$image->file_path,
|
$image->file_path,
|
||||||
'banner.png'
|
'banner.png'
|
||||||
)) {
|
) || str_ends_with($image->file_path, 'banner.jpeg')) {
|
||||||
$image->sizes = config('Images')
|
$image->sizes = config('Images')
|
||||||
->podcastBannerSizes;
|
->podcastBannerSizes;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user