[wp-trac] [WordPress Trac] #44609: Different metadata and sizes coming when uploaded via media library and wp_insert_attachment()
WordPress Trac
noreply at wordpress.org
Mon Apr 15 21:03:15 UTC 2019
#44609: Different metadata and sizes coming when uploaded via media library and
wp_insert_attachment()
--------------------------+----------------------
Reporter: dipakbbsr | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Media | Version: 4.9.7
Severity: normal | Resolution: invalid
Keywords: | Focuses:
--------------------------+----------------------
Changes (by joemcgill):
* status: new => closed
* resolution: => invalid
* milestone: Awaiting Review =>
Comment:
Hi @dipakbbsr, thanks for the report. It's interesting that there are
encoding differences in the two serialized examples you provided, which
might account for some strange behavior, but the intermediate sizes are
created during this line, which should be consistent with what happens in
the back end:
{{{#!php
wp_update_attachment_metadata( $upload_id,
wp_generate_attachment_metadata( $upload_id, $new_file_path ) );
}}}
It could be a problem with the load order of the files, noting that you're
manually including `wp-admin/includes/image.php` and some required
functionality for properly handling resizing might not be available.
At this point, I would generally suggest trying to use the REST API for
uploading files from the front end. You might find some helpful info here:
https://wordpress.stackexchange.com/questions/209928/add-media-with-wp-
rest-api-v2. Trying to handle the upload process manually falls outside
the scope of what I would consider supported behavior.
I'm going to go ahead and close this for now, but if you do find that
there is a specific bug in the way the metadata is generated that you
think _should_ be supported, please feel free to reopen with more details.
Thanks!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44609#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list