Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r18827 r21014  
    5454        }
    5555        elseif ( $size == 'large' ) {
    56                 // we're inserting a large size image into the editor.  if it's a really
     56                // We're inserting a large size image into the editor. If it's a really
    5757                // big image we'll scale it down to fit reasonably within the editor
    58                 // itself, and within the theme's content width if it's known.  the user
     58                // itself, and within the theme's content width if it's known. The user
    5959                // can resize it in the editor if they wish.
    6060                $max_width = intval(get_option('large_size_w'));
    … …  
    328328 *
    329329 * @since 2.5.0
     330 * @uses apply_filters() Calls 'image_resize_dimensions' on $orig_w, $orig_h, $dest_w, $dest_h and
     331 *              $crop to provide custom resize dimensions.
    330332 *
    331333 * @param int $orig_w Original width.
    … …  
    343345        if ($dest_w <= 0 && $dest_h <= 0)
    344346                return false;
     347
     348        // plugins can use this to provide custom resize dimensions
     349        $output = apply_filters( 'image_resize_dimensions', null, $orig_w, $orig_h, $dest_w, $dest_h, $crop );
     350        if ( null !== $output )
     351                return $output;
    345352
    346353        if ( $crop ) {
    … …  
    456463        } else {
    457464                // all other formats are converted to jpg
    458                 $destfilename = "{$dir}/{$name}-{$suffix}.jpg";
     465                if ( 'jpg' != $ext && 'jpeg' != $ext )
     466                        $destfilename = "{$dir}/{$name}-{$suffix}.jpg";
    459467                if ( !imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) ) )
    460468                        return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
    … …  
    725733 */
    726734function img_caption_shortcode($attr, $content = null) {
     735        // New-style shortcode with the caption inside the shortcode with the link and image tags.
     736        if ( ! isset( $attr['caption'] ) ) {
     737                if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
     738                        $content = $matches[1];
     739                        $attr['caption'] = trim( $matches[2] );
     740                }
     741        }
    727742
    728743        // Allow plugins/themes to override the default caption template.
    … …  
    10971112/* <![CDATA[ */
    10981113        jQuery(document).ready(function($){
    1099                 $.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post_ID ); ?>");
     1114                $.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post_ID, 'relative' ); ?>");
    11001115        });
    11011116/* ]]> */
    … …  
    13791394 * @param string $url The URL that should be embedded.
    13801395 * @param array $args Additional arguments and parameters.
    1381  * @return string The original URL on failure or the embed HTML on success.
     1396 * @return bool|string False on failure or the embed HTML on success.
    13821397 */
    13831398function wp_oembed_get( $url, $args = '' ) {
    … …  
    14431458}
    14441459
    1445 ?>
     1460/**
     1461 * Prints default plupload arguments.
     1462 *
     1463 * @since 3.4.0
     1464 */
     1465function wp_plupload_default_settings() {
     1466        global $wp_scripts;
     1467
     1468        $max_upload_size = wp_max_upload_size();
     1469
     1470        $defaults = array(
     1471                'runtimes'            => 'html5,silverlight,flash,html4',
     1472                'file_data_name'      => 'async-upload', // key passed to $_FILE.
     1473                'multiple_queues'     => true,
     1474                'max_file_size'       => $max_upload_size . 'b',
     1475                'url'                 => admin_url( 'admin-ajax.php', 'relative' ),
     1476                'flash_swf_url'       => includes_url( 'js/plupload/plupload.flash.swf' ),
     1477                'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
     1478                'filters'             => array( array( 'title' => __( 'Allowed Files' ), 'extensions' => '*') ),
     1479                'multipart'           => true,
     1480                'urlstream_upload'    => true,
     1481        );
     1482
     1483        $defaults = apply_filters( 'plupload_default_settings', $defaults );
     1484
     1485        $params = array(
     1486                'action' => 'upload-attachment',
     1487        );
     1488
     1489        $params = apply_filters( 'plupload_default_params', $params );
     1490        $params['_wpnonce'] = wp_create_nonce( 'media-form' );
     1491        $defaults['multipart_params'] = $params;
     1492
     1493        $settings = array(
     1494                'defaults' => $defaults,
     1495                'browser'  => array(
     1496                        'mobile'    => wp_is_mobile(),
     1497                        'supported' => _device_can_upload(),
     1498                ),
     1499        );
     1500
     1501        $script = 'var _wpPluploadSettings = ' . json_encode( $settings ) . ';';
     1502
     1503        $data = $wp_scripts->get_data( 'wp-plupload', 'data' );
     1504        if ( $data )
     1505                $script = "$data\n$script";
     1506
     1507        $wp_scripts->add_data( 'wp-plupload', 'data', $script );
     1508}
     1509add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
Note: See TracChangeset for help on using the changeset viewer.