Filter out duplicate media (#91)

Relates: #10194
This commit is contained in:
Daniel Siepmann 2022-11-30 10:35:44 +01:00 committed by GitHub
parent fd9507b525
commit bfa67d3514
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 15 deletions

View file

@ -363,6 +363,7 @@ class GeneralConverter implements Converter, LoggerAwareInterface
string $language
): string {
$data = [];
$idMainImage = '';
if ($entity->getPhoto() instanceof ForeignReference) {
$photo = $this->resolveForeignReference->resolve(
@ -370,6 +371,7 @@ class GeneralConverter implements Converter, LoggerAwareInterface
$language
);
if ($photo instanceof MediaObject) {
$idMainImage = $photo->getId();
$data[] = $this->getSingleMedia($photo, true, $language);
}
}
@ -379,7 +381,9 @@ class GeneralConverter implements Converter, LoggerAwareInterface
$image,
$language
);
if ($image instanceof MediaObject) {
// Do not import main image again as image.
// It is very likely that the same resource is provided as photo and image.
if ($image instanceof MediaObject && $image->getId() !== $idMainImage) {
$data[] = $this->getSingleMedia($image, false, $language);
}
}

View file

@ -32,6 +32,8 @@ Features
* Media has a new method ``getExtraImages()`` which will return everything from
``getImages()`` except the ``getMainImage()``.
We now also filter out the main image from other images, it will not exist twice
anymore.
Fixes
-----

File diff suppressed because one or more lines are too long