Enhancing Media Embedding and Alignment in W3CSS Theme for Drupal

Created on 9 July 2024, 4 months ago
Updated 16 August 2024, 3 months ago

Problem/Motivation

Align of media/images inserted by wysiwyg editor (ckeditor5) / media library is fine on preview (editor), but forced left-align and text-wrapped in normal (public) view. See print screen from editor and saved page.

There is no such problem with Olivero theme.

Steps to reproduce

Enable image align module in input format with ckeditor5.
Create some page with image, align it in wysiwyg editor and save.
No custom css.

Proposed resolution

Maybe some css missing or excessive? I "fixed" it by custom css:

.align-center {
  display: flex;
  justify-content: center;
}

div.w3-row.field.field--name-body.field--type-text-with-summary.field--label-hidden.w3-bar-item.field__item div {
  display: flex;
}

Some related discussions:

* https://www.drupal.org/project/drupal/issues/3347021 πŸ’¬ CKEditor 5 Media Embed alignment options does not work Closed: cannot reproduce

* https://www.drupal.org/project/ckeditor/issues/3126783 πŸ› Image align center not working Needs work

πŸ“Œ Task
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡ΏCzech Republic jc1

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

Comments & Activities

  • Issue created by @jc1
  • Assigned to flashwebcenter
  • Status changed to Fixed 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States flashwebcenter Austin TX

    Thank you for bringing this topic to my attention. The media module was not implemented in the theme yet. I have added a new Twig template for embedding media content within text fields. This new template ensures that your media content is styled beautifully and consistently when inserted into text areas.

    The work was pushed to the W3CSS Theme β†’ .

    Best wishes,
    Alaa

  • πŸ‡¨πŸ‡ΏCzech Republic jc1

    Thanks for quick response!

    I installed dev version of w3css theme (dev-2.x 1411a90), but it is still bad aligned and bad wrapped :(

  • πŸ‡ΊπŸ‡ΈUnited States flashwebcenter Austin TX

    Hello,

    Please ensure that you clear your caches and verify the presence of ../d8w3css/css/components/embedded-media.css. I have tested the functionality, and it is working on the demo site https://amun.flashwebcenter.com/page/introducing-solo-third-generation-w....





    Best wishes,
    Alaa

  • πŸ‡¨πŸ‡ΏCzech Republic jc1

    I disabled custom css (checkbox), flushed cache (on performance page) and force refresh page. It's same.

    find . -iname "embedded-media.css"
    ./web/themes/contrib/d8w3css/css/components/embedded-media.css
    ./web/core/themes/olivero/css/components/embedded-media.css

    composer show drupal/* |grep d8
    drupal/d8w3css dev-2.x 1411a90 Speed, Elegance & Ease of Development and Use

  • πŸ‡¨πŸ‡ΏCzech Republic jc1

    P.S. Custom css disabled in Amun V2 Theme settings. There is no custom css in W3CSS Theme V2.

  • πŸ‡ΊπŸ‡ΈUnited States flashwebcenter Austin TX

    Hello,

    It appears there might be a CSS conflict that is overriding the default settings if your site is not behaving like the demo site. Without a URL, I am unable to inspect the page and identify the conflict. If you cannot provide a URL, I recommend comparing your site to the demo site and following the differences to pinpoint the issue.

    Best regards,
    Alaa

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

  • πŸ‡¨πŸ‡ΏCzech Republic jc1

    Hello.

    I'm sorry for late response (holidays).

    Tried some upgrade/downgrade of d8w3css and upgrade anything else. Still not right aligned (like center).

    There are some custom css, but tested with disabled custom css and deleted custom css too.

    URL is https://www.stinadla.net/picture-align-test

    If I disable "float: left" for .node .field--name-field-image, .node .field--name-field-media-image (d8w3css/css/components/default-node.css?si9c7l), align is fine.

  • πŸ‡ΊπŸ‡ΈUnited States flashwebcenter Austin TX

    No problem, and happy holidays!

    I looked into the link and found that the default style for the image/media field had a left float. This style should only apply to images or media outside of any text fields. I've updated the CSS to ensure that this styling now only applies when these fields are direct children of the node content.

    The work was pushed to the W3CSS Theme Dev β†’ .

    Best wishes,
    Alaa

  • πŸ‡¨πŸ‡ΏCzech Republic jc1

    It's fine now. Thanks for your great themes and (also quick) support!

  • πŸ‡ΊπŸ‡ΈUnited States flashwebcenter Austin TX

    You’re welcome; I’m glad it worked out.

Production build 0.71.5 2024