Commit Graph

294 Commits

Author SHA1 Message Date
Ryan Boren 7ce1968d15 In media_buttons(), consult global post_ID if get_post() comes up with nothing.
Default postID to 0 in wp_enqueue_media().

Props nacin
fixes #22085


git-svn-id: https://develop.svn.wordpress.org/trunk@22846 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-26 22:03:37 +00:00
Daryl Koopersmith 383e24fcfe Add print_media_templates action to allow custom templates to be added. props ocean90. fixes #22565, see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22832 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-25 21:45:30 +00:00
Ryan Boren 7fbcbebc3d Handle attachments that have an empty mime type or a mime type without a subtype.
Props SergeyBiryukov
fixes #22532


git-svn-id: https://develop.svn.wordpress.org/trunk@22830 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-23 16:32:21 +00:00
Daryl Koopersmith f20573509b Media: Use a full uploader status view in the inline uploader. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22825 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-22 12:54:49 +00:00
Daryl Koopersmith 2070f5ca49 Media: Add uploader error detection to the inline uploader view as well. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22824 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-22 12:35:05 +00:00
Daryl Koopersmith 99def3ec51 Media: Make friends with media_upload_form. Adds notices for browser incompatibility, upload limits, maximum file size, and large file issues to the uploader. fixes #22243, see #22186, #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22821 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-22 11:46:03 +00:00
Daryl Koopersmith 77ed607d8e Media: Make the pre-upload-ui hooks share an element with the post-upload-ui hooks. see #22186, #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22819 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-22 10:57:43 +00:00
Daryl Koopersmith b007f89d0d Media: Display WordPress and plupload error messages whenever an upload fails. see #22243, #22186, #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22818 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-22 10:56:10 +00:00
Andrew Nacin f44d1d009e WP_Image_Editor: the last stand.
* Have wp_get_image_editor() rather than WP_Image_Editor::get_instance(). Having static factory methods would be less confusing if there weren't also static methods tied to individual editor implementations.
 * Lazy-load the WP_Image_Editor base class and editor implementations.
 * Have WP_Image_Editor_GD::supports_mime_type() actually check which types it supports.
 * Deprecate gd_edit_image_support() in favor of wp_image_editor_supports().

props DH-Shredder, scribu, markoheijnen. fixes #22356. see #6821.



git-svn-id: https://develop.svn.wordpress.org/trunk@22817 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-22 09:52:16 +00:00
Daryl Koopersmith ff6ae18d2d Media: Add global upload progress to the sidebar. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22816 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-22 09:32:21 +00:00
Daryl Koopersmith 4a99fa363e Media: Move sidebar from the frame view to the attachment browser view. Prevents juggling sidebar visibility state, and makes managing sidebar contents more reasonable. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22809 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-22 06:30:25 +00:00
Daryl Koopersmith bf42e8a402 Media: Make the window-wide uploader a subview of the frame view.
Allows the uploader to leverage the ready event to know when it has been attached to the page.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22790 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-21 20:27:49 +00:00
Andrew Nacin e4759d815d Support attachment_fields_to_save and attachment_fields_to_edit for attachments going through post.php. see #22186. see #21391.
git-svn-id: https://develop.svn.wordpress.org/trunk@22783 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-21 18:53:00 +00:00
Daryl Koopersmith 8ce1f39c6c Media: Move the new sections of media-upload.js to media-editor.js to allow the media modal to be used on the front end and prevent dependency conflicts with older themes and plugins. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22770 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-21 16:46:32 +00:00
Daryl Koopersmith 9a2033cabc Media: Backwards compatibility for the many send_to_editor filters. props nacin. see #22186, #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22768 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-21 16:02:20 +00:00
Daryl Koopersmith 493572fd09 Media: Backwards compatibility for the disable_captions filter. see #22186, #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22761 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-21 14:27:22 +00:00
Andrew Nacin 59be9048dd Stop inserting title attributes for images inserted into the editor by modifying get_image_send_to_editor(), not the generic get_image_tag().
see #18984, [22409].



git-svn-id: https://develop.svn.wordpress.org/trunk@22747 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-21 11:50:30 +00:00
Daryl Koopersmith 8e6aa60fa4 Media: Dynamically generate attachment filters using get_post_mime_types().
Moves `get_post_mime_types()` from `wp-admin/includes/post.php` to `wp-includes/post.php`.

fixes #22514, see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22743 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-21 10:18:59 +00:00
Andrew Nacin db7dc96921 Media: For pages, use 'Insert into page' rather than 'Insert into post'.
Custom post types can use the media_view_strings filter. No new post type "labels" for now.

see #22712. see #21092 (and #19696).



git-svn-id: https://develop.svn.wordpress.org/trunk@22735 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-20 23:22:03 +00:00
Daryl Koopersmith 76c67989a7 Media: Add filters to the media library. fixes #22514, see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22712 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-20 13:49:35 +00:00
Daryl Koopersmith ce06a037dd Media: Attachment checkboxes now function as such. fixes #22462, see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22706 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-20 11:10:04 +00:00
Andrew Nacin 1f5e71fd3a Add media_view_settings and media_view_strings hooks. fixes #21092 for 3.5. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22702 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-20 02:58:33 +00:00
Andrew Nacin 870d1d05db Revert [22675]. wp_mime_type_icon() is more accurate when given a post ID, rather than a mime type. The "speed" mostly comes down to the ordering of cache hits, rather than any performance issues like #22503. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22677 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-19 08:44:37 +00:00
Andrew Nacin 68a3e80d4d wp_mime_type_icon() is faster when given a mime type, rather than a post ID. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22675 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-19 08:39:14 +00:00
Daryl Koopersmith 893c538066 Media: Only show the alignment setting when viewing an image. fixes #21836, see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22671 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-19 07:24:47 +00:00
Daryl Koopersmith 2411401f1b Media: Remove unused batch edit states and strings. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22658 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-19 03:11:48 +00:00
Daryl Koopersmith 101c5a5371 Media: Add a base view class.
* Centralizes view and subview management, unifying several disjointed constructs.
* Utilizes the `dispose` functionality found in Backbone master, providing a standard method for memory management.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22648 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-19 00:36:47 +00:00
Daryl Koopersmith 7ce0c04466 Media: Wrap the embed screen's alignment setting in a div instead of a label to avoid default browser selection behavior. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22608 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-16 01:49:11 +00:00
Daryl Koopersmith ee694739ec Media: Update in-grid captions.
* Use input fields instead of textboxes (which provide better handling for smaller attachments).
* Provide `data-setting` properties to properly sync the changes.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22603 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-15 23:53:06 +00:00
Daryl Koopersmith bf105feb4e Media: Enter batch insert workflow by editing the selection instead of having an explicit button. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22594 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-15 02:36:06 +00:00
Daryl Koopersmith 55a3f09ec4 Media: Improve image size-related UI and code.
* Add dimensions to the "sizes" dropdown.
* Ensure a `full` size is generated in `wp_prepare_attachment_for_js()`.
* Print the dimensions for the full size in the attachment summary (instead of those for the current size).
* When generating the attachment view's template, map `imageSize()` to the `size` property instead of overriding the default data.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22580 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-14 22:08:02 +00:00
Daryl Koopersmith 57e98a72d2 Media: Convert templates to use a data variable instead of with statements. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22578 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-14 21:51:41 +00:00
Daryl Koopersmith f684d6abc2 Media: Make edit gallery button use new media. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22568 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-14 09:06:10 +00:00
Daryl Koopersmith 9fb6e29102 Media: Add support for applicable *-upload-ui hooks.
Supports pre-upload-ui, pre-plupload-upload-ui, post-plupload-upload-ui, post-upload-ui.

see #22186, #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22557 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-13 01:50:08 +00:00
Daryl Koopersmith e0df0a74ca Media: Improve backwards compatibility for image_size_names_choose filter. see #22186, #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22556 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-13 01:23:18 +00:00
Daryl Koopersmith 4ee51a98cb Media: Add an "upload more files" button to upload states. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22552 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-12 23:52:17 +00:00
Daryl Koopersmith f6a737ed34 Media: Add Embed from URL tab.
Note: There is a bug that currently blocks adding several successive embeds.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22547 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-12 05:57:12 +00:00
Daryl Koopersmith 9cd3c458c7 Media: Ensure variables in the attachment details template have defined defaults.
* Adds styling to the upload progress bar in the attachment details template.
* Defines the `filename` attribute when Plupload creates the client-side `Attachment` model.

fixes #22410, see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22543 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-11 05:16:41 +00:00
Daryl Koopersmith 57b09463e6 Media: Add backwards compatibility for attachment_fields_to_edit and attachment_fields_to_save. see #22186.
git-svn-id: https://develop.svn.wordpress.org/trunk@22541 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-11 01:26:42 +00:00
Daryl Koopersmith 5096f387d1 Media: Add custom URL as an option to attachment display properties. see #21390, #22206.
git-svn-id: https://develop.svn.wordpress.org/trunk@22537 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-10 20:36:46 +00:00
Daryl Koopersmith 62fe5ba600 Media: Add title, caption, and alt text, and attachment info to sidebar.
* Improve sidebar styles.
* Separate the hybrid title/caption field.
* Improve the sidebar image thumbnail.
* Remove filenames from inside the non-image icon thumbnail.
* Properly sync title/caption/alt.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22532 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-10 18:25:04 +00:00
Daryl Koopersmith fefaea2cf1 Media: Add instructions to drag and drop to reorder images on gallery and batch edit pages.
Removes search boxes from these pages as well.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22529 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-10 09:11:33 +00:00
Andrew Nacin e6fcf3b013 Don't unnecessarily translate media upload tab strings. see #22186.
git-svn-id: https://develop.svn.wordpress.org/trunk@22524 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-10 07:56:17 +00:00
Daryl Koopersmith 847a00f84b Media: Backwards compatibility for media_upload_tabs.
* Adds `createIframeStates()` to the `MediaFrame` view. It creates states and bindings for the `media_upload_tabs` output, and is included on `MediaFrame.Post` by default.
* Hijacks `tb_remove()` when the media modal is open to ensure the modal closes correctly.
* Adds a `chromeless` parameter to thickbox media tab URLs to render the UI without the old row of tabs.

see #22186, #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22523 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-10 07:51:37 +00:00
Daryl Koopersmith f8002c7752 Media: Relocate localization to wp_enqueue_media(). see #22186, #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22516 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-10 00:37:13 +00:00
Daryl Koopersmith b06d75f58b Media: Add size dropdown to attachment display settings in the media modal. fixes #22206, see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22493 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-09 06:15:25 +00:00
Daryl Koopersmith 2189575beb Media: Add wp_enqueue_media to easily include all media dependencies.
Also, media templates now print on `wp_footer`.

props sushkov. fixes #22060, see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22489 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-09 04:57:25 +00:00
Andrew Nacin 97490d8911 Allow wp_plupload_default_settings() to be called multiple times without doubling up the output. see #22060.
git-svn-id: https://develop.svn.wordpress.org/trunk@22488 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-09 04:51:25 +00:00
Daryl Koopersmith 68d143d20d Media: Improve sidebar handling and make attachment display properties attachment-specific.
`wp.mce.media`
* Watch all workflows for the `insert` event and attempt to insert the current state's `selection` if it exists.
* Fetch and pass attachment display properties through to `wp.media.string.image()`.

`wp.media.controller.Region`
* Separate the concept of events and modes.
* All events triggered on a `Region` trigger both `event` and `event:mode` callbacks.
* When a mode is deactivated, `deactivate` and `deactivate:mode` events are fired.
* When a mode is activated, `activate` and `activate:mode` events are fired.

`wp.media.controller.Library`
* Remove the `details()`, `buildDetails()`, and `clearDetails()` methods that juggled sidebar views. Instead, handle the sidebar views using modes.

`wp.media.controller.Gallery`
* Shift the overloaded `sidebar()` method to use modes.

`wp.media.view.MediaFrame.Post`
* Declare `activate:mode` event bindings using an nested object to reduce repetition.
* Update sidebar activation callbacks.

`wp.media.view.Settings`
* Refactor to leverage HTML data attributes and implicit values (instead of setting the fallback whenever an object was created). This has the additional benefit that gallery shortcode parameters are not output when the user has left them set to the default.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22466 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-08 14:15:09 +00:00
Daryl Koopersmith b636e94e47 Media: Integrate the gallery workflow with the media menu.
`wp.media.model.Query.more()`
* If a request has already been sent out for more attachments, return that request object instead of creating another.

`wp.media.controller.Region`
* A region allows views to be swapped in and out of a section of the page without either view having to know about the other.
* Application components can use the same callbacks and resources by leveraging `Region.mode()`, which triggers a set of callbacks to create or transform the current view, but only if necessary.

`wp.media.view.Frame`
* Leverage `Region` controllers instead of forcing states to swap view objects, which causes states to fit more comfortably in the controller-camp.
* Add `previous()`, a method to fetch the previous state `id`.
* Separate out the default settings over several objects (so blank frames can be instantiated).

`wp.media.view.MediaFrame`
* The base `Frame` used for media management: handles integration with the `Modal` and `UploaderWindow` views.

`wp.media.view.MediaFrame.Post`
* Includes all default media states and callbacks necessary for inserting media into a post.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22437 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-07 20:14:41 +00:00
Daryl Koopersmith c0ab768faa Use Mustache-insipired template tags.
Underscore's default ERB-style templates are incompatible with PHP when asp_tags is enabled. As a result, we've settled on an alternative syntax that should be familiar to devs: Mustache-inspired for interpolating and escaping content, and ERB-inspired for execution.

	`{{{a}}}` - interpolating
	`{{ a }}` - escaping
	`<# a #>` - execution

props rmccue. fixes #22344, see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22415 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-07 08:41:17 +00:00
Andrew Nacin 8d1e29d8b6 Stop adding title attributes to images (in the old media uploader). props martythornley. fixes #18984.
git-svn-id: https://develop.svn.wordpress.org/trunk@22409 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-06 23:23:03 +00:00
Daryl Koopersmith 737ed62a1c Streamlining media, part I.
The main goal here is to rearrange the media components in a modularized structure to support more linear workflows. This is that structure using the pre-existing workflows, which will be improved over the course of the next few commits.

This leaves a few pieces a bit rough around the edges: namely gallery editing and selecting a featured image.

The fine print follows.

----

'''Styles'''
* Tightened padding around the modal to optimize for a smaller default screen size.
* Added a light dashed line surrounding the modal to provide a subtle cue for the persistent dropzone (which is evolving into a power user feature since we now have a dedicated `upload` state).
* Add a size for `hero` buttons.
* Remove transitions from frame subviews (e.g. menu, content, sidebar, toolbar).

----

'''Code'''

`wp.media.controller.StateManager`
* Don't fire `activate` and `deactivate` if attempting to switch to the current state.

`wp.media.controller.State`
* Add a base state class to bind default methods (as not all states will inherit from the `Library` state).
* On `activate`, fire `activate()`, `menu()`, `content()`, `sidebar()`, and `toolbar()`.
* The menu view is often a shared object (as its most common use case is switching between states). Assign the view to the state's `menu` attribute.
* `menu()` automatically fetches the state's `menu` attribute, attaches the menu view to the frame, and attempts to select a menu item that matches the state's `id`.

`wp.media.controller.Library`
* Now inherits from `wp.media.controller.State`.

`wp.media.controller.Upload`
* A new state to improve the upload experience.
* Displays a large dropzone when empty (a `UploaderInline` view).
* When attachments are uploaded, displays management interface (a `library` state restricted to attachments uploaded during the current session).

`wp.media.view.Frame`
* In `menu()`, `content()`, `sidebar()`, and `toolbar()`, only change the view if it differs from the current view. Also, ensure `hide-*` classes are properly removed.
*

`wp.media.view.PriorityList`
* A new container view used to sort and render child views by the `priority` property.
* Used by `wp.media.view.Sidebar` and `wp.media.view.Menu`.
* Next step: Use two instances to power `wp.media.view.Toolbar`.

`wp.media.view.Menu` and `wp.media.view.MenuItem`
* A new `PriorityList` view that renders a list of views used to switch between states.
* `MenuItem` instances have `id` attributes that are tied directly to states.
* Separators can be added as plain `Backbone.View` instances with the `separator` class.
* Supports any type of `Backbone.View`.

`media.view.Menu.Landing`
* The landing menu for the 'insert media' workflow.
* Includes an inactive link to an "Embed from URL" state.
* Next steps: only use in select cases to allot for other workflows (such as featured images).

`wp.media.view.AttachmentsBrowser`
* A container to render an `Attachments` view with accompanying UI controls (similar to what the `Attachments` view was when it contained the `$list` property).
* Currently only renders a `Search` view as a control.
* Next steps: Add optional view counts (e.g. "21 images"), upload buttons, and collection filter UI.

`wp.media.view.Attachments`
* If the `Attachments` scroll buffer is not filled with `Attachment` views, continue loading more attachments.
* Use `this.model` instead of `this.controller.state()` to allow `Attachments` views to have differing `edge` and `gutter` properties.
* Add `edge()`, a method used to calculate the optimal dimensions for an attachment based on the current width of the `Attachments` container element.
* `edge()` is currently only enabled on resize, as the relative positioning and CSS transforms used to center thumbnails are suboptimal when coupled with frequent resizing.
* Next steps: For infinite scroll performance improvements, look into absolutely positioning attachment views and paging groups of attachment views.

`wp.media.view.UploaderWindow`
* Now generates a `$browser` element as the browse button (instead of a full `UploaderInline` view). Using a portable browse button prevents us from having to create a new `wp.Uploader` instance every time we want access to a browse button.

`wp.media.view.UploaderInline`
* No longer directly linked to the `UploaderWindow` view or its `wp.Uploader` instance.
* Used as the default `upload` state view.

`wp.media.view.Selection`
* An interactive representation of the selected `Attachments`.
* Based on the improved workflows, this is likely overkill. For simplicity's sake, will probably remove this in favor of `SelectionPreview`.

----

see #21390.



git-svn-id: https://develop.svn.wordpress.org/trunk@22362 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-04 22:59:12 +00:00
Daryl Koopersmith 18723b0970 Media: Reduce button size for the link gallery setting. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22345 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-31 21:03:27 +00:00
Daryl Koopersmith 80cd7ad468 Fix positioning of attachment thumbnail overlays.
Prevents the overlay from blocking buttons inside the attachment preview, such as the remove button in the gallery editor.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22343 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-31 20:34:50 +00:00
Daryl Koopersmith 3a64c92cf1 Add gallery settings to the media modal.
* Abstracts `wp.media.view.AttachmentDisplaySettings` into `wp.media.view.Settings` for managing lists of settings with button groups and select boxes. Settings can optionally be tied to a user setting (i.e. using `getUserSetting`).
* Adds `wp.media.view.Settings.AttachmentDisplay`.
* Adds `wp.media.view.Settings.Gallery`.

see #21390, #21815.


git-svn-id: https://develop.svn.wordpress.org/trunk@22340 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-31 19:22:25 +00:00
Daryl Koopersmith 3ca8808c3b Add dynamic attachment view sizing. Removes the attachment view zooming in the process. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22324 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-29 18:05:03 +00:00
Daryl Koopersmith bc29728df2 Add attachment details to the media sidebar.
* Also moves most of the `Frame` view's `createSelection` method to a real `Selection` model (which inherits from the `Attachments` model).
* Properly assigns the library within the `Gallery` state, allowing for the `Gallery` state to inherit from the `Library` state.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22323 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-29 15:13:02 +00:00
Daryl Koopersmith 6e387bb2db Add inline uploader UI to media modal sidebar. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22322 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-29 07:38:13 +00:00
Daryl Koopersmith 8fe5b79380 Add a sidebar to the media modal.
* Adds `wp.media.view.Sidebar`, to aid in rendering the sidebar.
* Removes the `directions` from the `Attachments` view and shifts search into a separate view (`wp.mce.view.Search`) that can be relocated at will. This also serves to simplify the `Attachments` view by removing the nested `list` and `$list` parameters.
* Show the toolbar on the featured image workflow, effectively requiring confirmation before closing the dialog.

see #21390, #21776, #21808.


git-svn-id: https://develop.svn.wordpress.org/trunk@22321 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-29 06:56:23 +00:00
Daryl Koopersmith 15c451d2f6 Give media a heart transplant.
Revises the concept of the media controller and workspace views (i.e. two central points of control) to be more granular. The main media object is now the `Frame`, which is a hybrid view and state machine.

The state machine is a collection of states, which are just generic instances of `Backbone.Model`. This circumvents the problem of juggling global parameters when changing states. Each state contains its own event loop. All events are also forwarded to the frame itself (as is the case in all model/collection relationships).

The frame view contains several regions, each of which can be overridden without harming or re-rendering the other regions. These work well when used in conjunction with the state machine events.

This removes the upload sidebar (don't worry, visible upload UI will return). Drag and drop uploading still works. The ability to upload has been abstracted into its own view (instead of being attached to the central workspace view).

Editing galleries is temporarily broken — the gallery creation and editing experiences will be unified in a future patch.

Adds events to detect dragging changes in `wp.Uploader` and adds methods to detect and leverage browser support for CSS3 transitions.

see #21390, #21809.


git-svn-id: https://develop.svn.wordpress.org/trunk@22320 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-28 23:29:17 +00:00
Daryl Koopersmith 9e8cd23bdb Add attachment display settings to the media modal.
* Add a media view for button groups.
* Add button dropdown containers.
* Add a dropdown property to the button media model.

fixes #22206, #21814, see #21390, #21813, #21598.


git-svn-id: https://develop.svn.wordpress.org/trunk@22247 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-16 19:25:17 +00:00
Andrew Nacin 70f79ffef3 Fix typo and don't always return false from image_make_intermediate_size(). props gandham, see #22181.
git-svn-id: https://develop.svn.wordpress.org/trunk@22225 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-13 06:46:17 +00:00
Ryan Boren 167cc00a84 Check for WP_Error return from WP_Image_Editor::get_instance().
Props markoheijnen
see #6821


git-svn-id: https://develop.svn.wordpress.org/trunk@22192 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-11 18:59:41 +00:00
Daryl Koopersmith a5fc058f89 Media Modal: Improve attachment remove button styles. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22184 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-11 04:11:47 +00:00
Daryl Koopersmith b0d215a771 Media Modal: Show progress bars for uploading images, and adjust progress bar styles to compensate for the darker attachment background. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22176 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-11 00:36:42 +00:00
Daryl Koopersmith d27568e703 Caption editing in the media modal library.
* Adds a `describe` option to the workflow controller to support inline caption editing.
* For images, descriptions are mapped to the `caption` attribute.
* For other media items, descriptions are mapped to the `title` attribute.
* Descriptions are saved when the textarea's `change` event fires (i.e. when the textarea is blurred).

fixes #21807, see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22173 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 23:32:48 +00:00
Daryl Koopersmith a830567a92 Correctly insert non-image attachments as links.
* Adds `wp.media.string.link( attachment )` for printing attachment links.
* Adds the `link` attribute to `Attachment` models that corresponds to the link to the attachment post.

see #21390, #21836.


git-svn-id: https://develop.svn.wordpress.org/trunk@22170 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 21:54:21 +00:00
Daryl Koopersmith 344d0ad7c1 Media JS: Ensure the subtype key has a default set.
Prevents undefined JS errors in the attachments view template.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22160 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 10:08:43 +00:00
Daryl Koopersmith 14de8ad04a Show filenames for non-image attachments in the new media modal.
Also passes all attachment model attributes to the attachment view template by default (instead of selecting specific values).

see #21390, #21836.


git-svn-id: https://develop.svn.wordpress.org/trunk@22159 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 09:55:47 +00:00
Daryl Koopersmith d4f1bc45ac Media JS: Improve markup and CSS of the modal view's title.
Also improves the accuracy of closing the modal when the backdrop is clicked (which became error-prone around the title bar in [22144]).

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22158 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 09:40:22 +00:00
Daryl Koopersmith 04143f286a When editing a gallery, images can now be added from the media library.
Enables the "Add images from media library" button when editing. The UX has room for improvement, but it's a start.

see #21390, #21809.


git-svn-id: https://develop.svn.wordpress.org/trunk@22157 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 09:30:22 +00:00
Daryl Koopersmith 6500957bcd Improve styling and markup for gallery and attachment MCE views.
Attachment views can now inherit from the theme's `editor-style.css` — just have any rules that apply to the `img` tag apply to `.editor-attachment` as well.

Adds a non-functional edit button to gallery views.

see #21390, #21813, #21815.


git-svn-id: https://develop.svn.wordpress.org/trunk@22154 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 06:47:22 +00:00
Daryl Koopersmith 561c3b7837 Improve media modal title bar styling. props helenyhou, see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22144 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-09 02:56:39 +00:00
Daryl Koopersmith b26a4d2cde Remove the attachment quick-insert button from the media modal. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22138 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-09 00:21:52 +00:00
Daryl Koopersmith 91a3c62b3f Better thumbnail previews in the image editor.
* Images are auto-cropped, then fit to the preview on hover (with a slight delay). This is an experiment; we'll see how it turns out.
* Various style changes.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22137 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-08 23:20:04 +00:00
Daryl Koopersmith d43c390e2b Use the new media modal to insert galleries into TinyMCE and the text editor.
'''Galleries'''

* Gallery insertion from the new media modal (into TinyMCE, the text editor, etc).
* Gallery previews in TinyMCE now use the `wp.mce.views` API.
* Disables the TinyMCE `wpgallery` plugin.
* Gallery previews consist of the first image of the gallery and the appearance of a stack. This will later be fleshed out to include more images/functionality (including editing the gallery, gallery properties, and showing the number of images in the gallery).
* Multiple galleries can be added to a single post.
* The gallery MCE view provides a bridge between the `wp.shortcode` and `Attachments` representation of a gallery, which allows the existing collection to persist when a gallery is initially created (preventing a request to the server for the query).


'''Shortcodes'''

* Renames `wp.shortcode.Match` to `wp.shortcode` to better expose the shortcode constructor.
* The `wp.shortcode` constructor now accepts an object of options instead of a `wp.shortcode.regexp()` match.
* A `wp.shortcode` instance can be created from a `wp.shortcode.regexp()` match by calling `wp.shortcode.fromMatch( match )`.
* Adds `wp.shortcode.string()`, which takes a set of shortcode parameters and converts them into a string.* Renames `wp.shortcode.prototype.text()` to `wp.shortcode.prototype.string()`.
* Adds an additional capture group to `wp.shortcode.regexp()` that records whether or not the shortcode has a closing tag. This allows us to improve the accuracy of the syntax used when transforming a shortcode object back into a string.

'''Media Models'''

* Prevents media `Query` models from observing the central `Attachments.all` object when query args without corresponding filters are set (otherwise, queries quickly amass false positives).
* Adds `post__in`, `post__not_in`, and `post_parent` as acceptable JS attachment `Query` args.
* `Attachments.more()` always returns a `$.promise` object.

see #21390, #21809, #21812, #21815, #21817.


git-svn-id: https://develop.svn.wordpress.org/trunk@22120 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-05 04:23:59 +00:00
Ryan Boren 7790af3154 Introduce WP_Image_Editor, WP_Image_Editor_Imagick, and WP_Image_Editor_GD. Abstracts image editing API and adds support for ImageMagick.
Props DH-Shredder, kurtpayne, markoheijnen
see #6821


git-svn-id: https://develop.svn.wordpress.org/trunk@22094 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-01 20:59:06 +00:00
Daryl Koopersmith d6d359a1bc Move wp_max_upload_size and dependencies to wp-includes. props johnjamesjacoby. see #21390, fixes #21867.
git-svn-id: https://develop.svn.wordpress.org/trunk@22073 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 20:59:57 +00:00
Daryl Koopersmith 7354809132 Add quick insert buttons to attachment views in the library and remove buttons to attachment views in the gallery editor. see #21390, #21809.
git-svn-id: https://develop.svn.wordpress.org/trunk@22053 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 07:45:26 +00:00
Daryl Koopersmith d2b6d050f4 Use the attachment id to look up the mime type icon instead of the raw mime type string, as wp_mime_type_icon() runs a broader search when using an id. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22043 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 06:07:56 +00:00
Daryl Koopersmith 0dd940e0c1 First pass on TinyMCE attachment in-editor UI.
* Adds in-editor UI for image attachments. Most of this UI should be able to migrate to all images in a future commit.
* Removes the wpeditimage TinyMCE plugin from the default plugins array.
* Add `wp.media.fit`, a helper method to constrain dimensions based upon a maximum width and/or height.
* Add html attribute parsing and string generation utilities (currently stored in mce-views).
* Calling `remove` on a TinyMCE views now ensures that the the parent and references are removed as well.
* Fixes a bug where we weren't sending the full array of results to matches in wp.mce.view.

see #21390, #21812, #21813.



git-svn-id: https://develop.svn.wordpress.org/trunk@22012 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-26 14:12:54 +00:00
Andrew Nacin ab2f77ebd0 Move WP_Embed into its own file. props ocean90. fixes #20533.
git-svn-id: https://develop.svn.wordpress.org/trunk@21999 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-25 08:39:26 +00:00
Andrew Nacin 84ca011876 Always attempt to embed URLs in content, removing the Auto-embeds (autoembed_urls) option.
Remove the UI for setting the default width and height for embeds. Width was confusing as it
was blank by default (inheriting the content width from the theme, or 500px). The height is
now calculated as 1.5x the content width, or 1000px, whichever is smaller.

The [embed] shortcode can still receive manual height and width attributes. This just removes
the global settings.

props wonderboymusic. see #21719.



git-svn-id: https://develop.svn.wordpress.org/trunk@21998 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-25 07:10:09 +00:00
Andrew Nacin 991be145a9 Use the regular post type UI for editing single media items (attachments).
* Attachments now go through post.php, edit_post(), the like, and have show_ui set to true.
 * Taxonomies attached to the media library now appear in the admin menu (if show_ui).
 * Editing, cropping, uploading, etc. is still very rough, but mostly functional.

API-wise:
 * New function: get_taxonomies_for_attachments(). Like get_taxonomies(), for taxonomies specifically registered against attachments.
 * Brings taxonomy support from the posts list table to the media list table. Expect them to converge soon.
 * wp_insert_attachment() now handles taxonomies like wp_insert_post(). Also expect them to converge soon.
 * New edit_form_after_title hook.

props helenyhou, ocean90. see #21391.



git-svn-id: https://develop.svn.wordpress.org/trunk@21948 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-21 22:52:54 +00:00
Daryl Koopersmith 7b999727ce Rename the attachment-thumbnail class in the media modal Attachment view to prevent conflicts with wp_get_attachment_image(). see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@21909 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-19 01:10:17 +00:00
Andrew Nacin 22ba686ace Don't sanitize include and exclude in gallery_shortcode(), as this is handled further down the stack, and better. props SergeyBiryukov, TobiasBg. fixes #21827.
git-svn-id: https://develop.svn.wordpress.org/trunk@21833 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-13 17:06:25 +00:00
Andrew Nacin 78cc9eac60 oEmbed uses author_can(), not current_user_can(). props DrewAPicture, fixes #21880.
git-svn-id: https://develop.svn.wordpress.org/trunk@21830 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-13 16:42:43 +00:00
Daryl Koopersmith 7955b982b3 Prevent img elements in the media modal from being draggable. see #21390.
Browsers natively support dragging img elements, which would then set off the drop zone in the modal. We disable this by setting the draggable attribute to false.



git-svn-id: https://develop.svn.wordpress.org/trunk@21785 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-07 22:09:40 +00:00
Daryl Koopersmith c7eca8e2d5 Use icons for non-image attachments in the new media modal. see #21836, #21390, #21808.
git-svn-id: https://develop.svn.wordpress.org/trunk@21784 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-07 21:27:07 +00:00
Mark Jaquith d906bd2f70 use 'ids' parameter for explicit attachment ordering in [gallery] shortcodes. fixes #21816
git-svn-id: https://develop.svn.wordpress.org/trunk@21778 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-06 19:19:56 +00:00
Daryl Koopersmith 073cd101f5 Add checks for attachment metadata when formatting attachments for JS.
Prevents notices from causing malformed ajax responses.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@21772 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-06 09:50:41 +00:00
Daryl Koopersmith ec0ee0164c Adds UI for media modal toolbars, buttons, and the selected item(s) status.
Currently uses actions for inserting media into a post as an example (hence the raw text). To test a workflow that supports multiple selection, run the following in your browser's JavaScript console:

	wp.media({ multiple: true });

see #21390, #21808.



git-svn-id: https://develop.svn.wordpress.org/trunk@21769 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-06 07:46:15 +00:00
Ryan Boren 31ec698423 Use get_post() instead of global $post.
Make the $post argument to get_post() optional, defaulting to the current post in The Loop.

Props nacin
see #21309


git-svn-id: https://develop.svn.wordpress.org/trunk@21735 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-04 16:29:28 +00:00
Daryl Koopersmith 436bf0016f Media: Use numeric timestamps instead of string-based timestamps when preparing an attachment for js.
We use the 'date' attribute to create Javascript Date objects. The Date() constructor has better cross-browser compatibility when numeric arguments are passed to the constructor.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@21691 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-31 19:14:43 +00:00
Daryl Koopersmith 5a4a17687a Add new media workflow scripts, styles, and templates.
Please note that this commit does not integrate media into the existing UI. If you would like to see the new UI, navigate to the post editor and run the following in your browser's Javascript console:

	new wp.media.controller.Workflow().render().modal.open();


The Javascript is broken up into two files, with the slugs media-models and media-views.

* media-models: The models are UI agnostic, and can be used independent of the views. If you'd like to create custom UIs, this is the script for you.

* media-views: This is the Media Experience. The views (and controllers) depend on the models (which are listed as a dependency and will automatically be included thanks to wp_enqueue_script). The views also require the media templates, media-view styles, and the plupload bridge settings. Perhaps we should create a function to include the whole shebang, but in the meantime...

To include media-views in the admin, run the following PHP in or after 'admin_enqueue_scripts':

	wp_enqueue_script( 'media-views' );
	wp_enqueue_style( 'media-views' );
	wp_plupload_default_settings();
	add_action( 'admin_footer', 'wp_print_media_templates' );

see #21390.



git-svn-id: https://develop.svn.wordpress.org/trunk@21683 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-31 04:54:23 +00:00
Andrew Nacin c7ba96ddaa Introduce wp_prepare_attachment_for_js(). Prepares an attachment post object to be JSON-encoded and fitted into an Attachment model, for 3.5 media.
props koopersmith. see #21390.



git-svn-id: https://develop.svn.wordpress.org/trunk@21680 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-31 02:04:40 +00:00
Ryan Boren de06b81360 Remove return ref from all calls to get_post()
Return WP_Post from get_default_post_to_edit()
Replace all calls to get_page() with get_post()
see #21309


git-svn-id: https://develop.svn.wordpress.org/trunk@21597 602fd350-edb4-49c9-b593-d223f7449a82
2012-08-23 20:01:10 +00:00
Ryan Boren 46dd14c4e1 Introduce wp_oembed_remove_provider(). Props r-a-y. fixes #16327
git-svn-id: https://develop.svn.wordpress.org/trunk@21351 602fd350-edb4-49c9-b593-d223f7449a82
2012-07-26 20:18:27 +00:00
Daryl Koopersmith 299642f86b Theme Customizer: Fix scrolling on iOS and Kindle Fire. props azaozz, helenyhou. fixes #20805.
Also fixes uploader UIs on iOS and Kindle Fire by improving wp.Uploader.
Adds mobile viewport specifications.
Moves scrollbar back to fixed positioning.


git-svn-id: https://develop.svn.wordpress.org/trunk@21014 602fd350-edb4-49c9-b593-d223f7449a82
2012-06-06 21:45:17 +00:00