Skip to content

Commit 5810926

Browse files
committed
Do not list a picture without a valid uuid
1 parent 30f5c55 commit 5810926

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

‎src/Controller/ContentElement/AbstractGalleryCreatorController.php‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,11 @@ protected function addAlbumPicturesToTemplate(GalleryCreatorAlbumsModel $albumMo
314314
}
315315

316316
if (null !== ($picturesModel = GalleryCreatorPicturesModel::findByPk($rowPicture['id']))) {
317-
// Prevent overriding items with same basename
318-
$arrPictures[$basename.'-id-'.$rowPicture['id']] = $this->pictureUtil->getPictureData($picturesModel, $contentModel);
317+
if($picturesModel->uuid && $this->pictureUtil->pictureExists($picturesModel))
318+
{
319+
// Prevent overriding items with same basename
320+
$arrPictures[$basename.'-id-'.$rowPicture['id']] = $this->pictureUtil->getPictureData($picturesModel, $contentModel);
321+
}
319322
}
320323
}
321324

‎src/Util/PictureUtil.php‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ public function getPictureData(GalleryCreatorPicturesModel $pictureModel, Conten
5353
return null;
5454
}
5555

56-
if (!is_file($filesModel->getAbsolutePath())) {
57-
return null;
58-
}
59-
6056
// Meta
6157
$arrMeta = Frontend::getMetaData($filesModel->meta, $objPage->language);
6258

@@ -66,7 +62,7 @@ public function getPictureData(GalleryCreatorPicturesModel $pictureModel, Conten
6662

6763
$arrMeta['title'] = $pictureModel->caption ?? $arrMeta['title'];
6864

69-
// Get thumb dimensions
65+
// Get the thumb dimensions
7066
$arrSize = StringUtil::deserialize($contentElementModel->gcSizeDetailView);
7167

7268
$href = null;
@@ -98,15 +94,15 @@ public function getPictureData(GalleryCreatorPicturesModel $pictureModel, Conten
9894
return [
9995
'ownerRow' => $ownerModel ? $ownerModel->row() : [],
10096
'filesRow' => $filesModel->row(),
101-
'pictureRow' => $pictureModel->row,
97+
'pictureRow' => $pictureModel->row(),
10298
'albumRow' => $pictureModel->getRelated('pid')->row(),
10399
'meta' => $arrMeta,
104100
'href' => $href,
105101
'localMediaSrc' => $localMediaSrc,
106102
'socialMediaSrc' => $socialMediaSrc,
107103
'exif' => $this->galleryCreatorReadExifMetaData ? $this->getExif(new File($filesModel->path)) : [],
108104
'singleImageUrl' => StringUtil::ampersand($objPage->getFrontendUrl((Config::get('useAutoItem') ? '/' : '/items/').Input::get('items').'/img/'.$filesModel->name, $objPage->language)),
109-
'figureUuid' => $pictureModel->addCustomThumb ? $pictureModel->customThumb : $filesModel->uuid,
105+
'figureUuid' => $pictureModel->addCustomThumb && $pictureModel->customThumb ? $pictureModel->customThumb : $filesModel->uuid,
110106
'figureSize' => !empty($arrSize) ? $arrSize : null,
111107
'figureHref' => $href,
112108
'figureOptions' => [
@@ -133,4 +129,15 @@ public function getExif(File $file): array
133129

134130
return $exif;
135131
}
132+
133+
public function pictureExists(GalleryCreatorPicturesModel $picturesModel): bool
134+
{
135+
$objFile = FilesModel::findByUuid($picturesModel->uuid);
136+
137+
if (null !== $objFile) {
138+
return is_file($objFile->getAbsolutePath());
139+
}
140+
141+
return false;
142+
}
136143
}

0 commit comments

Comments
 (0)