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: Reduce attribute storage requirements #1986

Closed
aduth opened this issue Jul 24, 2017 · 6 comments
Closed

Gallery: Reduce attribute storage requirements #1986

aduth opened this issue Jul 24, 2017 · 6 comments
Assignees
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Media Anything that impacts the experience of managing media [Priority] High Used to indicate top priority items that need quick attention
Milestone

Comments

@aduth
Copy link
Member

aduth commented Jul 24, 2017

Related: #1785 (comment)

Here's an example of markup generated from a gallery block with two images:

<!-- wp:core/gallery {"images":[{"sizes":{"thumbnail":{"height":150,"width":150,"url":"http://editor.dev/wp-content/uploads/2017/07/snow-150x150.jpeg","orientation":"landscape"},"medium":{"height":199,"width":300,"url":"http://editor.dev/wp-content/uploads/2017/07/snow-300x199.jpeg","orientation":"landscape"},"large":{"height":349,"width":525,"url":"http://editor.dev/wp-content/uploads/2017/07/snow-1024x680.jpeg","orientation":"landscape"},"full":{"url":"http://editor.dev/wp-content/uploads/2017/07/snow.jpeg","height":1275,"width":1920,"orientation":"landscape"}},"mime":"image/jpeg","type":"image","subtype":"jpeg","id":237,"url":"http://editor.dev/wp-content/uploads/2017/07/snow.jpeg","alt":""},{"sizes":{"thumbnail":{"height":150,"width":150,"url":"http://editor.dev/wp-content/uploads/2017/07/landscape-mountains-nature-clouds-150x150.jpg","orientation":"landscape"},"medium":{"height":144,"width":300,"url":"http://editor.dev/wp-content/uploads/2017/07/landscape-mountains-nature-clouds-300x144.jpg","orientation":"landscape"},"large":{"height":253,"width":525,"url":"http://editor.dev/wp-content/uploads/2017/07/landscape-mountains-nature-clouds-1024x493.jpg","orientation":"landscape"},"full":{"url":"http://editor.dev/wp-content/uploads/2017/07/landscape-mountains-nature-clouds.jpg","height":616,"width":1280,"orientation":"landscape"}},"mime":"image/jpeg","type":"image","subtype":"jpeg","id":234,"url":"http://editor.dev/wp-content/uploads/2017/07/landscape-mountains-nature-clouds.jpg","alt":""}]} -->
<div class="wp-block-gallery alignnone columns-2 is-cropped">
    <figure class="blocks-gallery-image"><img src="http://editor.dev/wp-content/uploads/2017/07/snow.jpeg" alt="" /></figure>
    <figure class="blocks-gallery-image"><img src="http://editor.dev/wp-content/uploads/2017/07/landscape-mountains-nature-clouds.jpg" alt="" /></figure>
</div>
<!-- /wp:core/gallery -->

We should be more responsible about the amount of data we store, ideally the minimal necessary to display the content on the front-end and still be able to "make sense" of the block's structure in the editor.

For example, we may not need:

  • Sizes, orientation, mime type, type, subtype (request as needed in the editor)
  • Alt (parse from content? or request from API as needed)

For most of these, an image ID should be sufficient.

cc @mkaz @mtias

@aduth aduth added the [Feature] Blocks Overall functionality of blocks label Jul 24, 2017
@mtias mtias added the [Feature] Media Anything that impacts the experience of managing media label Jul 24, 2017
@nylen
Copy link
Member

nylen commented Jul 24, 2017

Previously: #1469 (comment)

We should not store data in comment attributes for this block, it leads to ugly generated markup and invites the two data sources (comments, HTML) to get out of sync.

@joemcgill
Copy link
Member

It may be worth reviewing the attributes that are uses in the current gallery shortcode (docs). I agree that for images, we probably only need the attachment ids.

@mkaz
Copy link
Member

mkaz commented Jul 31, 2017

Thanks for opening up this issue @aduth - so as of now the edit gallery modals require the sizes and thumbnails to be specified which as you point out leads to a bunch of extra data being stored.

@joemcgill - we need core media to be updated to only need the data for attachment ids and it getting all of the appropriate thumbnails and data needed for edit. In my testing opening the modal did end up needing sizes, mime, type, and subtype or various parts didn't show. Should I open a ticket for this?

@mkaz
Copy link
Member

mkaz commented Aug 1, 2017

After some discussion, the idea to address this issue is to not use the Media modals for editing a Gutenberg gallery only for adding images. The data is really only needed to reopen the modal with the images.

So editing (remove, reorder) of the gallery will be done in the block itself and then the data will not be necessary to store within comment attributes. See #2128 and #2129

@joemcgill
Copy link
Member

@mkaz Keeping editing in the inspector makes sense to me. We also have to keep in mind the flow for adding new images to an existing gallery. I still think we can get away with doing this by only passing IDs to the media library. I'll look into what might be needed from core's side later this week, but if you have any further details describing what barriers you ran into, that would be a big help.

@karmatosed karmatosed added the [Priority] High Used to indicate top priority items that need quick attention label Aug 3, 2017
@mtias mtias added this to the Beta 0.8.0 milestone Aug 4, 2017
@joemcgill joemcgill self-assigned this Aug 8, 2017
@mkaz
Copy link
Member

mkaz commented Aug 11, 2017

Fixed in #2294

@mkaz mkaz closed this as completed Aug 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Media Anything that impacts the experience of managing media [Priority] High Used to indicate top priority items that need quick attention
Projects
None yet
Development

No branches or pull requests

6 participants