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

Images: Adding images to a post doesn't also attach it #1586

Closed
jasmussen opened this issue Jun 29, 2017 · 9 comments
Closed

Images: Adding images to a post doesn't also attach it #1586

jasmussen opened this issue Jun 29, 2017 · 9 comments
Assignees
Labels
[Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended
Milestone

Comments

@jasmussen
Copy link
Contributor

This can cause theme issues.

@jasmussen jasmussen added the [Type] Bug An existing feature does not function as intended label Jun 29, 2017
@aduth
Copy link
Member

aduth commented Aug 18, 2017

Should be fixed as of #1967

@aduth aduth closed this as completed Aug 18, 2017
@rachelmcr
Copy link
Contributor

I tested publishing a photo post in Gutenberg 1.4.0 and the photo wasn't attached. Video of my publishing flow and other details here: https://test.wordpress.com/2017/10/13/image-posting-flow-gutenberg/

@aduth aduth reopened this Oct 13, 2017
@aduth
Copy link
Member

aduth commented Oct 13, 2017

To clarify, this appears to be specific to drag-and-drop upload, which uses its own implementation to upload to the WordPress REST API. Uploading using the media library within Gutenberg will correctly attach the image to the post.

@aduth
Copy link
Member

aduth commented Oct 13, 2017

The naive answer would be to inject _wpMediaViewsL10n.settings.post.id as parent property in the media upload:

return new wp.api.models.Media().save( null, {
data: data,
contentType: false,
} );

But...

  • Something is clobbering ``_wpMediaViewsL10n.settings` at runtime and it isn't accessible after page loda
  • This ties the media upload tool to the presence of a window global, and is less predictable by its implicitness (not pure). Ideally that which calls the upload would also pass the post ID as an argument.

For drag-and-drop, that happens in the image block transform:

{
type: 'files',
isMatch( files ) {
return files.length === 1 && files[ 0 ].type.indexOf( 'image/' ) === 0;
},
transform( files ) {
return createMediaFromFile( files[ 0 ] )
.then( ( media ) => createBlock( 'core/image', {
id: media.id,
url: media.source_url,
} ) );
},
},

This ties into #2473, where blocks (let alone transforms) don't currently have easy access to post state.

@mrleemon
Copy link
Contributor

Is the "Attached to this post" idea going to be deprecated with Gutenberg? I'm asking this because some custom post types I've seen out there (Portfolio, Events, Ads, etc...) use this to just display images attached to posts.

@karmatosed karmatosed added this to the Merge Proposal milestone Jan 25, 2018
@bobbingwide
Copy link
Contributor

Please can someone give this bug the attention it deserves? It's a backward compatibility issue.

@bobbingwide
Copy link
Contributor

I’d just like to point out that this problem occurs when using the Upload button in the Image block.

@mtias mtias added the [Feature] Media Anything that impacts the experience of managing media label Mar 6, 2018
@danielbachhuber
Copy link
Member

@joemcgill Did you get anywhere on this or can I help out with it?

@joemcgill
Copy link
Member

@danielbachhuber haven’t looked at it yet. Was hoping to have a go at it soon, but feel free.

@danielbachhuber danielbachhuber self-assigned this Apr 11, 2018
@karmatosed karmatosed modified the milestones: Merge Proposal, Merge Proposal: Media Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

9 participants