Order Media items

Created on 28 August 2020, over 4 years ago
Updated 18 June 2024, 6 months ago

Problem/Motivation

Default Media widget has an option to sort media items after upload items. I see the same JS code to do that, but I didn't understand how to work to enable this option.

Steps to reproduce

Create a custom form with a media_library element multivalue.

$form['image'] = [
      '#type' => 'media_library',
      '#allowed_bundles' => ['image'],
      '#title' => t('Upload your image'),
      '#default_value' => $image_default_value,
      '#description' => t('Upload or select your profile image.'),
      '#cardinality' => 4,
    ];

The media field has weight input and the drag-and-drop works. But when I save the content, the sort value doesn't apply.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡·Brazil igorbarato

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 States codechefmarc

    I've tested both patch #4 and patch #8. Both worked to re-order the images and save in the correct order, however patch #8 worked better for me as it continued to show a preview of the image (pre-save) whereas #4 required a save before I could see a preview.

  • πŸ‡ΊπŸ‡¦Ukraine Anna D

    I've tested #8 patch.
    Works fine for me.

Production build 0.71.5 2024