Skip to content

Commit

Permalink
Detect and replace custom crops (art directed)in srcset
Browse files Browse the repository at this point in the history
  • Loading branch information
virtruvio committed Jul 9, 2018
1 parent f1f3763 commit bd2827b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/ResponsiveImages/RegisteredResponsiveImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,18 @@ public function getUrls(): array

public function getSrcset(): string
{
$filesSrcset = $this->files
->map(function (ResponsiveImage $responsiveImage) {
return "{$responsiveImage->url()} {$responsiveImage->width()}w";
})
->implode(', ');
$filesSrcset = $this->files
->map(function (ResponsiveImage $responsiveImage) {
if ($this->media->hasCustomProperty('custom.art.'.$responsiveImage->width() ))
{
$customUrl = $this->media->getUrl(). $this->media->getCustomProperty('custom.art.'. $responsiveImage->width().'.qS');
$customUrl = str_replace('storage','xstorm', $customUrl);
return "{$customUrl} {$responsiveImage->width()}w";
} else {
return "{$responsiveImage->url()} {$responsiveImage->width()}w";
}
})
->implode(', ');

$shouldAddPlaceholderSvg = config('medialibrary.responsive_images.use_tiny_placeholders')
&& $this->getPlaceholderSvg();
Expand Down

0 comments on commit bd2827b

Please sign in to comment.