Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Introduce mediaDetails attribute; only define sizes when exists
  • Loading branch information
danielbachhuber committed Jul 3, 2018
commit a61fce9a58b8e49a9fc40d80634aeb25ff4b767c
7 changes: 5 additions & 2 deletions utils/mediaupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,18 @@ export function mediaUpload( {

return createMediaFromFile( mediaFile, additionalData ).then(
( savedMedia ) => {
const mediaObject = {
let mediaObject = {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can still use const, we are not changing the mediaObject reference we are just changing a key in the object.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can still use const, we are not changing the mediaObject reference we are just changing a key in the object.

This is bizarre and seems like a bug. Constant means constant, or unchanging. Reassignment, even to some subset of the data, isn't permitted in PHP.

I've made the change regardless 4f3acb7

alt: savedMedia.alt_text,
caption: get( savedMedia, [ 'caption', 'raw' ], '' ),
id: savedMedia.id,
link: savedMedia.link,
title: savedMedia.title.raw,
url: savedMedia.source_url,
sizes: get( savedMedia, [ 'media_details', 'sizes' ], {} ),
mediaDetails: {},
};
if ( has( savedMedia, ['media_details', 'sizes'] ) ) {
mediaObject.mediaDetails.sizes = get( savedMedia, [ 'media_details', 'sizes' ], {} );
}
setAndUpdateFiles( idx, mediaObject );
},
( response ) => {
Expand Down