File tree Expand file tree Collapse file tree
modules/graphql_image/src/Plugin/Deriver Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55use Drupal \Component \Plugin \Derivative \DeriverBase ;
66use Drupal \Core \Extension \ModuleHandlerInterface ;
77use Drupal \Core \Plugin \Discovery \ContainerDeriverInterface ;
8+ use Drupal \responsive_image \Entity \ResponsiveImageStyle ;
89use Symfony \Component \DependencyInjection \ContainerInterface ;
910
1011/**
@@ -42,8 +43,17 @@ public function __construct(ModuleHandlerInterface $moduleHandler) {
4243 * {@inheritdoc}
4344 */
4445 public function getDerivativeDefinitions ($ basePluginDefinition ) {
46+ /**
47+ * Add the 'responsive' field only if responsive image module is enabled
48+ * and there is at least one style defined in the system.
49+ *
50+ * @see \Drupal\graphql_image\Plugin\GraphQL\Enums\ResponsiveImageStyleId
51+ */
4552 if ($ this ->moduleHandler ->moduleExists ('responsive_image ' )) {
46- $ this ->derivatives ['responsive_image ' ] = $ basePluginDefinition ;
53+ $ imageStyles = ResponsiveImageStyle::loadMultiple ();
54+ if (!empty ($ imageStyles )) {
55+ $ this ->derivatives ['responsive_image ' ] = $ basePluginDefinition ;
56+ }
4757 }
4858 return parent ::getDerivativeDefinitions ($ basePluginDefinition );
4959 }
You can’t perform that action at this time.
0 commit comments