Allow image style to be selected in Text Editor's image dialog

Created on 9 August 2013, over 11 years ago
Updated 30 January 2023, about 2 years ago

Updated: Comment #212

Problem/Motivation

Inserting an image in the text editor dialog today allows the user to fiddle with image dimensions. It doesn't even have aspect ratio locking.

It's not great for the authoring experience nor for structured content reasons that users are defining the specific dimensions of every single image they insert. It'd be much better to allow them to choose from image styles โ€” just like we do for image fields.

Proposed resolution

Allow an image style to be selected in the image dialog, which gets stored in a data-image-style attribute, and is handled by a yet-to-be-added imagestyle filter.

Remaining tasks

  1. Initial patch: select image style in dialog, inserting that sets a data- attribute, and a filter transforms the end result.

User interface changes

  • The new ability to select an image style.
  • A new filter.

API changes

None.

Related Issues

โœจ Feature request
Status

Needs review

Version

10.1 โœจ

Component
CKEditor 5ย  โ†’

Last updated 2 days ago

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

  • Needs usability review

    Used to alert the usability topic maintainer(s) that an issue significantly affects (or has the potential to affect) the usability of Drupal, and their signoff is needed. When adding this tag, make it easy to review the issue. Make sure the issue summary describes the problem and the proposed solution. Screenshots usually help a lot! To get sign-off on issues with the "Needs usability review" tag, post about them in the #ux channel on Drupal Slack, and/or attend a UX meeting to demo the patch and get direct feedback from designers/UX folks/product management on next steps. If an issue represents a significant new feature, UI change, or change to the general "user experience" of Drupal, use Needs product manager review instead. See the scope of responsibilities for product managers.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille

    Here is a reroll for Drupal 10.0.

  • Status changed to Needs work about 2 years ago
  • The Needs Review Queue Bot โ†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • ๐Ÿ‡ท๐Ÿ‡ธSerbia super_romeo Belgrade

    Patch #428 can't not be applied anymore on D10.1.x.
    Is is still needed?

  • ๐Ÿ‡ต๐Ÿ‡ฑPoland alorenc Wolsztyn, ๐Ÿ‡ต๐Ÿ‡ฑ

    Updated drupal-2061377-437.patch, added fixes for the following issues:

    ------ ---------------------------------------------------------------------
    Line core/modules/image/image.module
    ------ ---------------------------------------------------------------------
    561 Function file_url_transform_relative not found.
    ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols
    ------ ---------------------------------------------------------------------

    ------ ---------------------------------------------------------------------
    Line core/modules/image/tests/src/Kernel/EditorImageStyleDialogTest.php
    ------ ---------------------------------------------------------------------
    102 Function file_save_data not found.
    ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols
    106 Function file_url_transform_relative not found.
    ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols
    ------ ---------------------------------------------------------------------

  • last update over 1 year ago
    Custom Commands Failed
  • last update over 1 year ago
    Patch Failed to Apply
  • Status changed to Needs review over 1 year ago
  • last update over 1 year ago
    Custom Commands Failed
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine i-trokhanenko Lutsk ๐Ÿ‡บ๐Ÿ‡ฆ

    Here is a reroll of #441 for Drupal 10.1.1

  • ๐Ÿ‡ณ๐Ÿ‡ฌNigeria chike Nigeria

    Patch #442 applied on Drupal 10.1.1 but no image styles are showing up in CKEditor. I did turn on 'Display image styles' for the editor and selected some image styles in the configuration but using the 'Insert image' button offers no image styles.

    Perhaps this feature is not yet targeted at CKEditor 5 as screenshot above is CKEditor 4.

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    CC failure

    Also such a feature will need a change record.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine ruslan piskarov Kyiv, Ukraine

    Is it for CKEditor 4 only?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Ck4 is gone from core so will only be CK5.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance GaรซlG Lille, France

    Yep, as far as I know, it's discussed in comments #423 to #425 above but has not yet been addressed.

    The current patches are for CKE4 and should rather be in a CK4 contrib module issue, probably depending on this one or restricted to Drupal 8/9. And this issue should be focused on core/CKE5, in which case it should be considered as having no patch for now (I just unchecked "display" on the available patches).

    If you need this feature on CKE5, the best available option for now is the Inline responsive images contrib module with a patch from ๐Ÿ“Œ Compatibility with CKEditor5 (default in D10 core) Needs work .

  • Assigned to COBadger
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States COBadger

    Revised 10.1 patch forthcoming.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • last update over 1 year ago
    Custom Commands Failed
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States COBadger

    Re-rolled patch for 10.1.x.

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    CC failure.

    Also appears there is no test coverage

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance GaรซlG Lille, France

    Please put CKE4 patches in the newly created โœจ Allow image style to be selected in Text Editor's image dialog Active . Patches here should contain a CKE5 plugin.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vsujeetkumar Delhi

    Missing Trait file in #449, Added and fixed the CCF issues. Keeps as in 'Needs Work' to address #450.

  • last update over 1 year ago
    Build Successful
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance GaรซlG Lille, France

    @vsujeetkumar: Thank you for your work, but as said above, please put this patch into #3392556 contrib issue instead. There is no chance for it to be accepted for core as it targets CKE4.

  • last update over 1 year ago
    Custom Commands Failed
  • last update over 1 year ago
    Custom Commands Failed
  • last update over 1 year ago
    Custom Commands Failed
  • last update over 1 year ago
    Custom Commands Failed
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    Custom Commands Failed
  • last update over 1 year ago
    Custom Commands Failed
  • last update over 1 year ago
    Custom Commands Failed
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium flyke

    #388 and #429: In case like me you are updating your Drupal and get stuck because you keep having an error like this:

    The import failed due to the following reasons:                                                                                           
      Unexpected error during import with operation update for filter.format.basic_html: The "filter_image_style" plugin does not ex  
      ist. Valid plugin IDs for Drupal\filter\FilterPluginManager are: filter_ckeditor_media_embed, editor_file_reference, filter_html, filter  
      _htmlcorrector, filter_caption, filter_html_escape, filter_html_image_secure, filter_null, filter_url, filter_align, filter_image_lazy_l  
      oad, filter_autop, gutenberg, linkit, media_embed                                                                                         
      Unexpected error during import with operation update for filter.format.gutenberg: The "filter_image_style" plugin does not exi  
      st. Valid plugin IDs for Drupal\filter\FilterPluginManager are: filter_ckeditor_media_embed, editor_file_reference, filter_html, filter_  
      htmlcorrector, filter_caption, filter_html_escape, filter_html_image_secure, filter_null, filter_url, filter_align, filter_image_lazy_lo  
      ad, filter_autop, gutenberg, linkit, media_embed

    Then the solution is to create a dummy filter with that ID. So I created a custom module containing mymodule/src/Plugin/Filter/FilterImageStyle.php with this content:

    <?php
    
    namespace Drupal\mymodule\Plugin\Filter;
    
    use Drupal\filter\FilterProcessResult;
    use Drupal\filter\Plugin\FilterBase;
    
    /**
     * Provides a filter just to fix the filter_image_style does not exist error.
     *
     * @Filter(
     *   id = "filter_image_style",
     *   title = @Translation("Fix filter_image_style error"),
     *   description = @Translation("This is just ot fix the filter_image_style does not exist error"),
     *   type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE,
     *   weight = 15
     * )
     */
    class FilterImageStyle extends FilterBase {
    
      /**
       * {@inheritdoc}
       */
      public function process($text, $langcode) {
        return new FilterProcessResult($text);
      }
    
    }

    Now after drush cr, you should be able to continue your work and make sure this filter is not used anywhere. For me I first exported all my config with drush cex -y. Then I searched my config/sync folder for 'filter_image_style' and removed the references to that. Then I imported updated config with drush cim -y.

  • ๐Ÿ‡ท๐Ÿ‡ดRomania claudiu.cristea Arad ๐Ÿ‡ท๐Ÿ‡ด

    This is #422 to work with Drupal 10.2 for whom might be interested

  • last update about 1 year ago
    Custom Commands Failed
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Martijn de Wit ๐Ÿ‡ณ๐Ÿ‡ฑ The Netherlands

    Drupal 10.2 is released

  • last update about 1 year ago
    Custom Commands Failed
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    Re-queued the tests for the 11.x branch.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    So we have issues with Cspell, PHPStan, PHPCS and I also think there is an issue with one of the JS files.

    Probably also best to re-roll this patch over to a MR so we can benefit from GitLab pipelines as well.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    So we have issues with Cspell, PHPStan, PHPCS and I also think there is an issue with one of the JS files.

    Probably also best to re-roll this patch over to a MR so we can benefit from GitLab pipelines as well.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance GaรซlG Lille, France

    @flyke @claudiu.cristea @Martijn de Wit @BramDriesen: please see #447 and #451.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States rishi kulshreshtha

    I came across this issue while working on D10 upgrade for one of my sites. Please refer to the attached patch for anyone looking for a backport patch.

    PS: Thanks to @TwoD for submitting the initial patch!

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States rishi kulshreshtha

    Please ignore the previous patch. The attached patch is the correct one, this includes the missing file core/lib/Drupal/Core/Entity/DependencyRemovalTrait.php.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Wow, blast from the past. I just stumbled upon this issue after not having seen it for a very long time (and after having started it โ€ฆ over a decade ago ๐Ÿ‘ด). Let's get this done at last!

    ๐Ÿ“Œ [11.x] Remove EditorLinkDialog, EditorImageDialog and EditorMediaDialog in Drupal 11 Fixed removed EditorImageDialog. So this should now become a CKEditor 5-specific issue. And the current patch already does that! ๐Ÿ‘

    Adjusting issue title + component.

    The issue summary's screenshots show CKEditor 4. They need to be updated.

    Review

    1. I see there's tests already! ๐Ÿ‘ Removed .
    2. There seem every many out of scope changes in this issue? This should not make any changes to FilterFormat or FilterBase. As long as that's the case, this issue will never land. Can we please extract those changes into blocking issues? ๐Ÿ™
    3. There's still a *.es6.js file in there. We haven't been using those in at least a year, so the current patch could never land as-is in Drupal 10. And โ€ฆ this is still targeting CKEditor 4? ๐Ÿ˜… CKEditor 4 is EOL, it's not part of Drupal core anymore. Fortunately, for CKEditor 5, there's reusable infrastructure for this kind of thing already: the DrupalElementStyle functionality in the drupalMedia plugin โ€” there's even a nice blog post about it that should make it much easier to get started.
    4. This is changing the default text format + editor config in the Standard install profile. Changes to core's install profiles always should happen in separate issues, because they are a different scope/consideration. Tagged for that.
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance GaรซlG Lille, France

    Note that there is a contrib module which provides this kind of feature, even for CKE5. In case it can help.
    https://www.drupal.org/project/inline_responsive_images โ†’

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States aubjr_drupal

    +1 for this feature getting in. I just ran into this need, and it seems like a no-brainer addition in the spirit of Starshot.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States gcalex5

    Re-roll of #455 for 10.3.x

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia jannakha Brisbane!

    patch #466 applies to D10.3, but selected image styles are not visible in CKEditor 5 while adding/editing image:

    Config works as expected:

    Selected image styles are not available in CKEditor5:

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly Hotfingers

    Regarding patch #462 after using it I can't access /admin/reports/status anymore, with no errors being shown at /admin/reports/dblog.

    Now I'm trying to remove it, as I went with the media library with view modes alternative, but then I get:

    [error] Drupal\Component\Plugin\Exception\PluginNotFoundException: The "filter_image_style" plugin does not exist.

    Like in #192, #388 and #429.

    I did some digging and as I understand, it seems like the filter is still present inside the text format entry of the DB, even after removing the patch.

    You can check with:

    SELECT * FROM config WHERE data LIKE '%filter_image_style%';

    That it's still inside the BLOB of the text format.

    How can I safely remove this patch and the DB entry? I don't want to mess with the DB directly, for obvious reasons.

    Thanks to anyone that can help.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany rgpublic Dรผsseldorf ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ช๐Ÿ‡บ

    @hotfingers: Just a wild guess, but I think you'd have to reenable the patch again, so that you have that filter plugin available again. This should bring everything back to life. Then, go to all your filter formats and make sure that you have disabled the plugin first and save these settings. None of your filter formats should have that plugin enabled. Only then I guess can you safely remove the patch again.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States j_s

    Also tested #466 and have the same issue with it as #467 on Drupal 10.3.6. I moved around the filter order and cleared cache with no success.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sachbearbeiter

    Is there any hope of finding this must-have feature in a release? I have no idea why Drupal is built on a modern PHP codebase and it is still not possible to provide basic UI functionalities for the editorial team?

  • Merge request !10767Resolve #2061377 "Drupalimage styles" โ†’ (Open) created by heddn
  • heddn Nicaragua

    There's a lot of re-work needed to make this work w/ CK5 and D11. https://www.drupal.org/node/3291493 โ†’ deprecated the image dialog forms. I'm going to leave this at NW for now. But I started some of the rebase work in https://git.drupalcode.org/project/drupal/-/merge_requests/10767. It is a pure rebase. From here on, we'll need to figure out how to make this work with CK5. I'm not taking that on at the moment.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 172s
    #385002
Production build 0.71.5 2024