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

Gallery Block: Remove unused attributes property in shortcode transformation #57356

Merged
merged 1 commit into from Dec 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 0 additions & 54 deletions packages/block-library/src/gallery/transforms.js
Expand Up @@ -13,10 +13,6 @@ import {
LINK_DESTINATION_NONE,
LINK_DESTINATION_MEDIA,
} from './constants';
import {
LINK_DESTINATION_ATTACHMENT as DEPRECATED_LINK_DESTINATION_ATTACHMENT,
LINK_DESTINATION_MEDIA as DEPRECATED_LINK_DESTINATION_MEDIA,
} from './v1/constants';
import { pickRelevantMediaFiles, isGalleryV2Enabled } from './shared';

const parseShortcodeIds = ( ids ) => {
Expand Down Expand Up @@ -177,56 +173,6 @@ const transforms = {
{
type: 'shortcode',
tag: 'gallery',

attributes: {
images: {
type: 'array',
shortcode: ( { named: { ids } } ) => {
if ( ! isGalleryV2Enabled() ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no check in transforms whether the Gallery block is v2 or not. However, since the Gallery block v2 is enabled in all WordPress versions supported by the current Gutenberg plugin, I don't think it is necessary to add this check to transforms.

return parseShortcodeIds( ids ).map( ( id ) => ( {
id: id.toString(),
} ) );
}
},
},
ids: {
type: 'array',
shortcode: ( { named: { ids } } ) => {
if ( ! isGalleryV2Enabled() ) {
return parseShortcodeIds( ids );
}
},
},
columns: {
type: 'number',
shortcode: ( { named: { columns = '3' } } ) => {
return parseInt( columns, 10 );
},
},
linkTo: {
type: 'string',
shortcode: ( { named: { link } } ) => {
if ( ! isGalleryV2Enabled() ) {
switch ( link ) {
case 'post':
return DEPRECATED_LINK_DESTINATION_ATTACHMENT;
case 'file':
return DEPRECATED_LINK_DESTINATION_MEDIA;
default:
return DEPRECATED_LINK_DESTINATION_ATTACHMENT;
}
}
switch ( link ) {
case 'post':
return LINK_DESTINATION_ATTACHMENT;
case 'file':
return LINK_DESTINATION_MEDIA;
default:
return LINK_DESTINATION_NONE;
}
},
},
},
transform( { named: { ids, columns = 3, link } } ) {
const imageIds = parseShortcodeIds( ids ).map( ( id ) =>
parseInt( id, 10 )
Expand Down