Allow code-driven customization of the default empty_srcset breakpoint

Created on 17 December 2015, almost 9 years ago
Updated 19 September 2023, about 1 year ago

Problem/Motivation

The picture module provides a default breakpoint 'empty_srcset'. Changes to this breakpoint (for example, we add a modifier) can not be exported.

Proposed resolution

A work around is not using the default empty_srcset and defining a custom 'project_empty_srcset' one, which can be exported. I filed this issue to find out if there's a better way to achieve this.

One solution would be to allow exporting the default mapping, but this might be tough to implement (i.e. lots of modules have problems like this, like file_entity) and we're limited by the capabilities of ctools.

Another options would be to document how to override the defaults programatically. For example this hook works great in our case:

/**
 * Implements hook_default_breakpoints_alter().
 *
 * Modify the default provided by picture.module. The modifiers can be
 * configured in the UI, but we alter it because ctools defaults cannot be
 * exported.
 */
function acme_default_breakpoints_alter(&$export) {
  if (isset($export['module.picture.empty_srcset'])) {
    $export['module.picture.empty_srcset']->multipliers['2x'] = '2x';
  }
}
Feature request
Status

Closed: outdated

Version

2.0

Component

Code

Created by

🇳🇱Netherlands jsst

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom lesleyfernandes

    I am closing all very old tickets that have not received comments for a long time. If someone is still facing these issues, please reopen it. Feel free to contribute with more info or a patch.

Production build 0.71.5 2024