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

[Gutenberg] Remove image count from gallery processor #15196

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ public GalleryBlockProcessor(String localId, MediaFile mediaFile, String siteUrl
}

@Override boolean processBlockJsonAttributes(JsonObject jsonAttributes) {
// The presence of `imageCount` means we have the new format, so return early to defer to recursive processing
if (jsonAttributes.has("imageCount")) {
return false;
}

// The new format does not have an `ids` attributes, so returning false here will defer to recursive processing
JsonArray ids = jsonAttributes.getAsJsonArray("ids");
if (ids == null || ids.isJsonNull()) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ object TestContent {
</figure>
<!-- /wp:image -->
"""
const val oldRefactoredGalleryBlock = """<!-- wp:gallery {"linkTo":"none","imageCount":3} -->
const val oldRefactoredGalleryBlock = """<!-- wp:gallery {"linkTo":"none"} -->
<figure class="wp-block-gallery blocks-gallery-grid has-nested-images columns-3 is-cropped">
$oldRefactoredGalleryBlockInnerBlocks</figure>
<!-- /wp:gallery -->
Expand Down Expand Up @@ -312,7 +312,7 @@ $oldRefactoredGalleryBlockInnerBlocks</figure>
<!-- /wp:image -->
"""

const val newRefactoredGalleryBlock = """<!-- wp:gallery {"linkTo":"none","imageCount":3} -->
const val newRefactoredGalleryBlock = """<!-- wp:gallery {"linkTo":"none"} -->
<figure class="wp-block-gallery blocks-gallery-grid has-nested-images columns-3 is-cropped">
$newRefactoredGalleryBlockInnerBlocks</figure>
<!-- /wp:gallery -->
Expand Down