Problem/Motivation

When card_image_overlays is set to true card_media is never used.

Steps to reproduce

Add this:

{% include 'radix:card' with {
    card_media: content.field_coverimage.0 ? content.field_coverimage|field_value : '',
    card_title: label,
    title_link: url,
    card_subtitle: content.field_subtitle.0 ? content.field_subtitle|field_value : '',
    card_body: card_body_rendered is real_content ? card_body_rendered : '',
    card_image_overlays: true,
  } %}

Proposed resolution

Instead this:

  {% if card_image_overlays %}
    {%
      include 'radix:image' with {
        src: card_image_src,
        image_utility_classes: card_image_classes|merge(['card-img'])
      }
    %}
    {%
      set card_body_classes = [
        'card-img-overlay'
      ]
    %}
  {% endif %}

Print card_media with the same conditions as used for slot_card_image_top and slot_card_image_bottom:

  {% if card_image_overlays %}
      {% if card_media|render %}
        {{ card_media }}
      {% elseif card_image_src %}
        {%
          include 'radix:image' with {
            src: card_image_src,
            image_utility_classes: card_image_classes|merge(['card-img'])
          }
        %}
        {%
          set card_body_classes = [
            'card-img-overlay'
          ]
        %}
     {% endif %}
  {% endif %}

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork radix-3526551

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

thomas.frobieter created an issue. See original summary.

thomas.frobieter’s picture

Status: Active » Needs review

Okay, done, but it is a problem to add the required 'card-img' class on the image within card_media? :/

However, it makes card_media work with the card image overlay.

  • doxigo committed d3156950 on 6.0.x
    Issue #3526551: Card SDC: card_media not working when...
doxigo’s picture

Status: Needs review » Fixed

removed - wrong thread

doxigo’s picture

doxigo’s picture

Status: Fixed » Needs review

doxigo’s picture

Status: Needs review » Fixed

Thanks a lot, Thomas. This is fixed for now, regarding the card-img class, not sure if this is straightforward since a media can also be, let's say, a video and so on. I think if it comes to it, we can either override the card component or maybe some sort of a custom hook that can detect the media within the card to add the class

  • doxigo committed d3156950 on feature/vite
    Issue #3526551: Card SDC: card_media not working when...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

anybody’s picture

@doxigo could you maybe tag a new release with this fix? Eventually after merging #3561424: radix:navbar SDC: navbar_container_utility_classes should be type array not string?