Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media_gallery field creating grey square making Gutenberg block unusable after copy-paste or editing in another language with WPML #1273

Open
MrZyr0 opened this issue Jan 21, 2025 · 0 comments

Comments

@MrZyr0
Copy link

MrZyr0 commented Jan 21, 2025

Version

  • Carbon Fields: 3.6.5
  • WordPress: 6.7.1
  • PHP: 8.1.30
  • WPML: 4.6.15

Expected Behavior

When I copy/paste a block with several images selected for a media_gallery field and refresh the page after saving it, the images should load correctly.
Even if the images don't load correctly, their names should still appear and their placeholder should be movable and deletable.

Image
Image

Actual Behavior

When working with image blocks in the editor. There are two following situations for one behaviour :

  1. When copying and pasting this block...
  2. When I refreshing the editor...
    the following block displays unmovable and undetectable grey squares instead of the images preview like excepted.

Image
Image

Container definition

Block::make('slider-gallery', __('Slider gallery', 'aaa'))
    ->set_description(__('Slider gallery', 'aaa'))
    ->set_category('media')
    ->set_icon('slides')
    ->set_keywords([__('media', 'aaa'), __('pictures', 'aaa'), __('photos', 'aaa'), __('gallery', 'aaa'), __('slider', 'aaa'), __('thumbnail', 'aaa')])
    ->set_mode('edit')
    ->set_style('crb-images-slider-block-stylesheet')
    ->add_fields([
      Field::make('text', 'crb_gallery_name', __('Title', 'aaa')),
      Field::make('select', 'crb_display_mode', __('Mode', 'aaa'))
        ->add_options([
          'slider-mode' => __('Simple', 'aaa'),
          'slider-mode-with-thumbnails' => __('With thumbnails', 'aaa'),
        ])
        ->set_default_value('slider-mode'),
      Field::make('media_gallery', 'crb_media_gallery', __('Add image', 'aaa'))
        ->set_type('image')
    ])
    ->set_render_callback()

Steps to Reproduce the Problem

  1. Create a block with a media_gallery field.
  2. Add this block to a page content or copy and paste this block from a page to another.
  3. Save the page and refresh the editor.
  4. Observe that the pasted block no longer displays the selected images, but instead shows grey squares.
  5. Edit the page in another language, and the same behavior occurs.

Possible workaround

  1. Open a version of the page in the other languages and disable the media attachment option "Duplicate uploaded media to translations"
  2. Go back to the "original" source post
  3. Fix the block
  4. It should be fixed on the other translations

Comments

I think the problem is linked to the way the plugin handles image loading, when they takes too long or creates an error. I have a Varnish cache on this project who struggles with pictures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant