]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/media-editor.js
WordPress 4.7-scripts
[autoinstalls/wordpress.git] / wp-includes / js / media-editor.js
index c4ff48426f33075a29bfcc70c85eb1de1bc2f184..3852543aa4eb1797ff50c8cf0553512b695c0434 100644 (file)
                 * @returns {Object} Joined props
                 */
                props: function( props, attachment ) {
-                       var link, linkUrl, size, sizes, fallbacks,
+                       var link, linkUrl, size, sizes,
                                defaultProps = wp.media.view.settings.defaultProps;
 
-                       // Final fallbacks run after all processing has been completed.
-                       fallbacks = function( props ) {
-                               // Generate alt fallbacks and strip tags.
-                               if ( 'image' === props.type && ! props.alt ) {
-                                       props.alt = props.caption || props.title || '';
-                                       props.alt = props.alt.replace( /<\/?[^>]+>/g, '' );
-                                       props.alt = props.alt.replace( /[\r\n]+/g, ' ' );
-                               }
-
-                               return props;
-                       };
-
                        props = props ? _.clone( props ) : {};
 
                        if ( attachment && attachment.type ) {
@@ -80,7 +68,7 @@
 
                        // All attachment-specific settings follow.
                        if ( ! attachment ) {
-                               return fallbacks( props );
+                               return props;
                        }
 
                        props.title = props.title || attachment.title;
                                props.rel = props.rel || 'attachment wp-att-' + attachment.id;
                        }
 
-                       return fallbacks( props );
+                       return props;
                },
                /**
                 * Create link markup that is suitable for passing to the editor
                        var img = {},
                                options, classes, shortcode, html;
 
+                       props.type = 'image';
                        props = wp.media.string.props( props, attachment );
                        classes = props.classes || [];
 
 
                        settings.post.featuredImageId = id;
 
-                       wp.media.post( 'set-post-thumbnail', {
-                               json:         true,
+                       wp.media.post( 'get-post-thumbnail-html', {
                                post_id:      settings.post.id,
                                thumbnail_id: settings.post.featuredImageId,
                                _wpnonce:     settings.post.nonce
                        }).done( function( html ) {
+                               if ( html == '0' ) {
+                                       window.alert( window.setPostThumbnailL10n.error );
+                                       return;
+                               }
                                $( '.inside', '#postimagediv' ).html( html );
                        });
                },
+               /**
+                * Remove the featured image id, save the post thumbnail data and
+                * set the HTML in the post meta box to no featured image.
+                */
+               remove: function() {
+                       wp.media.featuredImage.set( -1 );
+               },
                /**
                 * The Featured Image workflow
                 *
                 */
                frame: function() {
                        if ( this._frame ) {
+                               wp.media.frame = this._frame;
                                return this._frame;
                        }
 
 
                                wp.media.featuredImage.frame().open();
                        }).on( 'click', '#remove-post-thumbnail', function() {
-                               wp.media.view.settings.post.featuredImageId = -1;
+                               wp.media.featuredImage.remove();
+                               return false;
                        });
                }
        };
 
                                if ( 'link' === type ) {
                                        _.defaults( embed, {
-                                               title:   embed.url,
+                                               linkText: embed.url,
                                                linkUrl: embed.url
                                        });
 
                         */
                        link: function( embed ) {
                                return wp.media.post( 'send-link-to-editor', {
-                                       nonce:   wp.media.view.settings.nonce.sendToEditor,
-                                       src:     embed.linkUrl,
-                                       title:   embed.title,
-                                       html:    wp.media.string.link( embed ),
-                                       post_id: wp.media.view.settings.post.id
+                                       nonce:     wp.media.view.settings.nonce.sendToEditor,
+                                       src:       embed.linkUrl,
+                                       link_text: embed.linkText,
+                                       html:      wp.media.string.link( embed ),
+                                       post_id:   wp.media.view.settings.post.id
                                });
                        }
                },
                                workflow = this.add( id, options );
                        }
 
+                       wp.media.frame = workflow;
+
                        return workflow.open();
                },
 
 
                                        event.preventDefault();
 
-                                       // Remove focus from the `.insert-media` button.
-                                       // Prevents Opera from showing the outline of the button
-                                       // above the modal.
-                                       //
-                                       // See: https://core.trac.wordpress.org/ticket/22445
-                                       elem.blur();
-
                                        if ( elem.hasClass( 'gallery' ) ) {
                                                options.state = 'gallery';
                                                options.title = wp.media.view.l10n.createGalleryTitle;