/**
 * The Google Video embed handler callback. Google Video does not support oEmbed.
 *
 * @see WP_Embed::register_handler()
 * @see WP_Embed::shortcode()
 *
 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
 * @param array $attr Embed attributes.
 * @param string $url The original URL that was matched by the regex.
 * @param array $rawattr The original unmodified attributes.
 * @return string The embed HTML.
 */
function wp_embed_handler_googlevideo($matches, $attr, $url, $rawattr)
{
    // If the user supplied a fixed width AND height, use it
    if (!empty($rawattr['width']) && !empty($rawattr['height'])) {
        $width = (int) $rawattr['width'];
        $height = (int) $rawattr['height'];
    } else {
        list($width, $height) = wp_expand_dimensions(425, 344, $attr['width'], $attr['height']);
    }
    return apply_filters('embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&amp;hl=en&amp;fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always"></embed>', $matches, $attr, $url, $rawattr);
}
Пример #2
0
/**
 * The DailyMotion.com embed handler callback. DailyMotion does not support oEmbed.
 *
 * @see WP_Embed::register_handler()
 * @see WP_Embed::shortcode()
 *
 * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
 * @param array $attr Embed attributes.
 * @param string $url The original URL that was matched by the regex.
 * @param array $rawattr The original unmodified attributes.
 * @return string The embed HTML.
 */
function wp_embed_handler_dailymotion($matches, $attr, $url, $rawattr)
{
    // If the user supplied a fixed width AND height, use it
    if (!empty($rawattr['width']) && !empty($rawattr['height'])) {
        $width = (int) $rawattr['width'];
        $height = (int) $rawattr['height'];
    } else {
        list($width, $height) = wp_expand_dimensions(480, 291, $attr['width'], $attr['height']);
    }
    return apply_filters('embed_dailymotion', '<object width="' . esc_attr($width) . '" height="' . esc_attr($height) . '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param name="movie" value="http://www.dailymotion.com/swf/' . esc_attr($matches[3]) . '&amp;related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/' . esc_attr($matches[3]) . '&amp;related=0" type="application/x-shockwave-flash" width="' . esc_attr($width) . '" height="' . esc_attr($height) . '" allowFullScreen="true" allowScriptAccess="always"></embed></object>', $matches, $attr, $url, $rawattr);
}
Пример #3
0
 /**
  * Copied from Google Video handler in wp-includes/media.php
  */
 public function oembed_handler_brainshark($matches, $attr, $url, $rawattr)
 {
     // If the user supplied a fixed width AND height, use it
     if (!empty($rawattr['width']) && !empty($rawattr['height'])) {
         $width = (int) $rawattr['width'];
         $height = (int) $rawattr['height'];
     } else {
         list($width, $height) = wp_expand_dimensions(440, 366, $attr['width'], $attr['height']);
     }
     $pi = $matches[2];
     $html = '<object width="' . $width . '" height="' . $height . '" id="bsplayer94201" name="bsplayer94201" data="http://www.brainshark.com/brainshark/viewer/getplayer.ashx" type="application/x-shockwave-flash"><param name="movie" value="http://www.brainshark.com/brainshark/viewer/getplayer.ashx" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value="pi=' . $pi . '&dm=5&pause=1" /><a href="http://www.brainshark.com/brainshark/viewer/fallback.ashx?pi=' . $pi . '"><video width="' . $width . '" height="' . $height . '" controls="true" poster="http://www.brainshark.com/brainshark/brainshark.net/common/getimage.ashx?pi=' . $pi . '&w=' . $width . '&h=' . $height . '&sln=1"><source src="http://www.brainshark.com/brainshark/brainshark.net/apppresentation/getmovie.aspx?pi=' . $pi . '&fmt=2" /><img src="http://www.brainshark.com/brainshark/brainshark.net/apppresentation/splash.aspx?pi=' . $pi . '" width="' . $width . '" height="' . $height . '" border="0" /></video></a></object>';
     return apply_filters('embed_brainshark', $html, $matches, $attr, $url, $rawattr);
 }
Пример #4
0
/**
 * The Google Video embed handler callback.
 *
 * Google Video does not support oEmbed.
 *
 * @see WP_Embed::register_handler()
 * @see WP_Embed::shortcode()
 *
 * @param array  $matches The RegEx matches from the provided regex when calling wp_embed_register_handler().
 * @param array  $attr    Embed attributes.
 * @param string $url     The original URL that was matched by the regex.
 * @param array  $rawattr The original unmodified attributes.
 * @return string The embed HTML.
 */
function wp_embed_handler_googlevideo($matches, $attr, $url, $rawattr)
{
    // If the user supplied a fixed width AND height, use it
    if (!empty($rawattr['width']) && !empty($rawattr['height'])) {
        $width = (int) $rawattr['width'];
        $height = (int) $rawattr['height'];
    } else {
        list($width, $height) = wp_expand_dimensions(425, 344, $attr['width'], $attr['height']);
    }
    /**
     * Filter the Google Video embed output.
     *
     * @since 2.9.0
     *
     * @param string $html    Google Video HTML embed markup.
     * @param array  $matches The RegEx matches from the provided regex.
     * @param array  $attr    An array of embed attributes.
     * @param string $url     The original URL that was matched by the regex.
     * @param array  $rawattr The original unmodified attributes.
     */
    return apply_filters('embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&amp;hl=en&amp;fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always" />', $matches, $attr, $url, $rawattr);
}
 /**
  * Method for filtering the media's 'width' and 'height' attributes so that the theme can handle the 
  * dimensions how it sees fit.
  *
  * @since  1.6.0
  * @access public
  * @param  string  $html
  * @return string
  */
 public function filter_dimensions($html)
 {
     $_html = strip_tags($html, '<object><embed><iframe><video>');
     /* Find the attributes of the media. */
     $atts = wp_kses_hair($_html, array('http', 'https'));
     /* Loop through the media attributes and add them in key/value pairs. */
     foreach ($atts as $att) {
         $media_atts[$att['name']] = $att['value'];
     }
     /* If no dimensions are found, just return the HTML. */
     if (empty($media_atts) || !isset($media_atts['width']) || !isset($media_atts['height'])) {
         return $html;
     }
     /* Set the max width. */
     $max_width = $this->args['width'];
     /* Set the max height based on the max width and original width/height ratio. */
     $max_height = round($max_width / ($media_atts['width'] / $media_atts['height']));
     /* Fix for Spotify embeds. */
     if (!empty($media_atts['src']) && preg_match('#https?://(embed)\\.spotify\\.com/.*#i', $media_atts['src'], $matches)) {
         list($max_width, $max_height) = $this->spotify_dimensions($media_atts);
     }
     /* Calculate new media dimensions. */
     $dimensions = wp_expand_dimensions($media_atts['width'], $media_atts['height'], $max_width, $max_height);
     /* Allow devs to filter the final width and height of the media. */
     list($width, $height) = apply_filters('hybrid_media_grabber_dimensions', $dimensions, $media_atts, $this);
     /* Set up the patterns for the 'width' and 'height' attributes. */
     $patterns = array('/(width=[\'"]).+?([\'"])/i', '/(height=[\'"]).+?([\'"])/i', '/(<div.+?style=[\'"].*?width:.+?).+?(px;.+?[\'"].*?>)/i');
     /* Set up the replacements for the 'width' and 'height' attributes. */
     $replacements = array('${1}' . $width . '${2}', '${1}' . $height . '${2}', '${1}' . $width . '${2}');
     /* Filter the dimensions and return the media HTML. */
     return preg_replace($patterns, $replacements, $html);
 }
Пример #6
0
/**
 * 奇艺嵌入代码
 *
 * @version 0.13.9.3
 * @see WP_Embed::shortcode 参数来源
 *     
 * @param unknown $matches
 * @param unknown $attr
 * @param unknown $url
 * @param unknown $rawattr
 * @return mixed
 */
function wp_embed_handler_qiyi($matches, $attr, $url, $rawattr)
{
    if (!empty($rawattr['width']) && !empty($rawattr['height'])) {
        $width = (int) $rawattr['width'];
        $height = (int) $rawattr['height'];
    } else {
        list($width, $height) = wp_expand_dimensions(425, 230, $attr['width'], $attr['height']);
    }
    $tmp = idea_qiyi($url);
    $swf = $tmp['swf'];
    $id = $tmp['id'];
    $embed = <<<EOT
<embed type="application/x-shockwave-flash" src="{$swf}?vid={$id}" style="width: {$width}px;height:{$height}px" allowFullScreen="true" allowScriptAccess="always" />
EOT;
    return apply_filters('embed_qiyi', $embed, $matches, $attr, $url, $rawattr);
}
Пример #7
0
 public function filter_image_resize_dimensions($default, $orig_w, $orig_h, $dest_w, $dest_h, $crop)
 {
     if ($crop) {
         return null;
     }
     // let the wordpress default function handle this
     // don't crop, just resize using $dest_w x $dest_h as a maximum bounding box
     $crop_w = $orig_w;
     $crop_h = $orig_h;
     $s_x = 0;
     $s_y = 0;
     // note the use of wp_expand_dimensions() instead of wp_constrain_dimensions()
     list($new_w, $new_h) = wp_expand_dimensions($orig_w, $orig_h, $dest_w, $dest_h);
     // the return array matches the parameters to imagecopyresampled()
     return array(0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h);
 }