that kind of thinking lives in the older world of primarily text-based posts and when images were scarce. John Maeda • Design at WordCamp US 2016 make.wordpress.org/design/2016/12/04/design-at-wordcamp-us-2016 “ ”
ﬁle data to the ﬁlesystem. For most uploads, this is done in wp_handle_upload(). Before saving the ﬁle, check: • User capabilities • Is ﬁlesystem is writable • The ﬁletype is allowed Returns an array containing the ﬁle path, URL, and type on success.
combination of a WP_Post object with specialized post meta values. WordPress combines data passed in the upload request with data from the ﬁle itself to build post properties like title, content, and excerpt Once assembled, an attachment array is saved to the database using wp_insert_attachment() (or wp_insert_post() in the REST API).
ﬁle path relative to the uploads directory 3. Build an array of intermediate sizes to create by combining default image sizes with those deﬁned by add_image_size() 4. Use wp_get_image_editor() to get a WP_Image_Editor for creating intermediate ﬁles. Default image editors use either ImageMagick or GD. 5. Pass the array of sizes to the editor's mulit-resize() method. Make the ﬁles, return the data. 6. Extract EXIF/IPTC data (aperture, credit, camera, copyright, shutter speed, ISO, etc.)
the attachment metadata, it is saved to the database using the function wp_update_attachment_metadata() and the attachment ID is returned. Note: Additional metadata, like the `alt` attribute value, and context (for custom headers) may also be generated.
the ﬁle, creating an attachment post, and saving all relevant metadata, it can prepare the response to send back to the client. Traditionally this will use wp_prepare_attachment_for_js() to create a JSON representation of the attachment. The REST API, returns a response which is similar, but not identical. Server errors return as an HTTP 503 error.
us, but here are some ideas: 1. Asynchronous image generation 2. Make media a ﬁrst-class data type (WP_Image) 3. Streamline integration for 3rd party services 5. Post-upload image optimization (ImageOptim) 6. Support modern formats (WebP, SVG) 7. ¯\_(ツ)_/¯ Media Handling in WordPress Explained