Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
"drush.services.yml": "^9"
}
}
},
"require": {
"drupal/focal_point": "^2.1"
}
}
5 changes: 3 additions & 2 deletions responsive_image_effect.info.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Responsive image effect
description: Replaces Drupal image style url generator with a scale and crop image effect that can be specified via URL arguments.
package: Media
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10 || ^11

type: module

dependencies:
- drupal:image
- drupal:focal_point
- focal_point:focal_point
- drupal:media
4 changes: 3 additions & 1 deletion src/Entity/ResponsiveImageStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\Core\StreamWrapper\StreamWrapperManager;
use Drupal\Core\Utility\Error;
use Drupal\image\Entity\ImageStyle;

class ResponsiveImageStyle extends ImageStyle {
Expand Down Expand Up @@ -71,7 +72,8 @@ public function flush($path = NULL) {
}
}
catch (\Exception $e) {
watchdog_exception('responsive_image_effect', $e, 'problem finding responsive image derivatives');
$logger = \Drupal::logger('responsive_image_effect');
Error::logException($logger, $e);
}

return $this;
Expand Down
9 changes: 5 additions & 4 deletions src/PathProcessor/PathProcessorImageStyles.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ public function processInbound($path, Request $request) {
* Return true/false if the responsive image effect is set.
*/
protected function imageStyleHasResponsiveEffect($image_style) {
$image_style = ImageStyle::load($image_style);
foreach ($image_style->getEffects() as $effect) {
if ($effect instanceof ResponsiveImageEffect) {
return TRUE;
if ($image_style = ImageStyle::load($image_style)) {
foreach ($image_style->getEffects() as $effect) {
if ($effect instanceof ResponsiveImageEffect) {
return TRUE;
}
}
}
return FALSE;
Expand Down