-
Notifications
You must be signed in to change notification settings - Fork 8
Conversation
First pass. Fixes #62.
Very basic, needs much more polish. And styles.
Looks like @westonruter already commented but I saw this too:
Which was resulting in some JS errors in the preview render. I added some logic to ensure we are working against an array in the preview, but agree we should maybe consider returning just the image urls needed in attachments? Not entirely sure the best thing to do. 🤞 that 905edbc also clears up the travis issues. |
I disabled the code sniffer in a few lines as it was returning the following error about
Figured that didn't really apply here. |
@timmyc feel free to give the |
Cross-reference Gallery block: WordPress/gutenberg#740 |
First pass. Fixes #62.
Very basic, needs much more polish. And styles.
905edbc
to
88a5d0b
Compare
/** * TODO fix edit button */
@m1tk00 - excellent, I am not getting errors in the preview anymore!! Outside of the linting issues we are having on the branch now - the following flow appears to be broken for me:
In this scenario, I expected to be shown the same dialog state as seen when clicking the 'pencil' to edit a gallery within the editor: |
@timmyc yeah thats where I got stuck. I tried passing the data via the selected option but can't get it working |
@m1tk00 so looking at how the Gutenberg Gallery block performs the operation: https://github.com/WordPress/gutenberg/blob/master/blocks/media-upload-button/index.js#L124-L141 - they hook into the |
Ill try it in the morning and let you know :)
…On Mon, Aug 14, 2017 at 23:17 Timmy Crawford ***@***.***> wrote:
@m1tk00 <https://github.com/m1tk00> so looking at how the Gutenberg
Gallery block performs the operation:
https://github.com/WordPress/gutenberg/blob/master/blocks/media-upload-button/index.js#L124-L141
- they hook into the onOpen event then add in the selected items at that
point. Do you want to give that a try or do you want me to work on that
here?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKx1XGG6nrG9_FrPmYUi9UdhZNKfNWSkks5sYLl8gaJpZM4NOwVW>
.
|
@timmyc Ive managed to fix the edit button. It was calling a wrong media frame. Just pushed to the repo. |
@m1tk00 I'm still having issues with the edit flow - my selections are not being shown when clicking the Edit button. |
So the past 3 commits are me trying to get CI to pass :) - each time, there is an array test that seems to go 💥 like the latest:
Any ideas @westonruter? I tried to re-create the issue locally and could not, then again my phpcs knowledge is limited. |
@westonruter last I checked, I don't think gallery settings from the media frame, like columns, etc, are being saved to the widget. I was going to sweep through and test each setting to see what was left. |
previewContainer = control.$el.find( '.media-widget-preview' ); | ||
previewTemplate = wp.template( 'wp-media-widget-gallery-preview' ); | ||
|
||
if ( control.model.get( 'ids' ).length && ! control.model.get( 'attachemnts' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
! control.model.get( 'attachemnts' )
this looks like it can be eliminated. At least, it is misspelled.
return attachment.id !== id; | ||
} ); | ||
this.set( { | ||
'attachments': JSON.stringify( newAttachments ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think references to 'attachments' still needs to be eliminated.
} ); | ||
this.set( { | ||
'attachments': JSON.stringify( newAttachments ), | ||
'ids': _.map( newAttachments, 'id' ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this actually should be _.pluck( newAttachments, 'id' )
not map
.
I'm working on some improvements to the rendering and syncing of the gallery settings. |
…ng and rendering selected attachments
|
||
mediaFrameProps = control.mapModelToMediaFrameProps( control.model.toJSON() ); | ||
if ( mediaFrameProps.size ) { | ||
control.displaySettings.set( 'size', mediaFrameProps.size ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be used?
|
||
mediaFrameProps = control.mapModelToMediaFrameProps( control.model.toJSON() ); | ||
if ( mediaFrameProps.size ) { | ||
control.displaySettings.set( 'size', mediaFrameProps.size ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be used?
…since gallery settings are also replaced
@joemcgill there's one key thing thing left before I think we can call this ready to merge: customizations. When you have selected images for a gallery, you then see something like this: If you try supplying a caption then: And then it update, there is no changes made because there is no // Disable syncing of attachment changes back to server (except for deletions). See <https://core.trac.wordpress.org/ticket/40403>.
defaultSync = wp.media.model.Attachment.prototype.sync;
wp.media.model.Attachment.prototype.sync = function( method ) {
if ( 'delete' === method ) {
return defaultSync.apply( this, arguments );
} else {
return $.Deferred().rejectWith( this ).promise();
}
};
mediaFrame.on( 'close', function onClose() {
wp.media.model.Attachment.prototype.sync = defaultSync;
}); It seems that for the Gallery widget we must remove this logic or else a user will not be able to modify the image attributes. |
This passes all of the gallery properties as shortcode atts when rendereing the gallery on the front-end.
@westonruter I was looking at that syncing logic yesterday and agree with you that in this context, captions should be able to be synced back to the underlying attachment. Your updates to the syncing of props between the widget control and the media frame seem to fix the issues I had noticed but the gallery attributes weren't being used to render the gallery shortcode on the front end, so I pushed another quick commit to resolve that issue. Will do some more testing, but other than the caption issue, things are looking good from my end. Just a note that captions are a bit tricky because some themes disregard captions when they render galleries. |
@joemcgill excellent, thanks. Once you merge this PR then we'll release a new version of the feature plugin to get out to testers for next week prior to core merge. |
@westonruter Got a chance to this again after e5ee972, and captions updates are now saving back to the model correctly. Going to go ahead and merge so we can get this into more hands. Nice work 🎉 |
Great work everyone! |
The plugin auto-deployed to WordPress.org so it is now available for all to test: https://wordpress.org/plugins/wp-core-media-widgets/ |
Fixes #62.
See https://core.trac.wordpress.org/ticket/41914