当前位置: 首页>>代码示例>>PHP>>正文


PHP Jetpack::get_content_width方法代码示例

本文整理汇总了PHP中Jetpack::get_content_width方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::get_content_width方法的具体用法?PHP Jetpack::get_content_width怎么用?PHP Jetpack::get_content_width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jetpack的用法示例。


在下文中一共展示了Jetpack::get_content_width方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: vine_embed_video

/**
 * Vine embed code:
 * <iframe class="vine-embed" src="https://vine.co/v/bjHh0zHdgZT" width="600" height="600" frameborder="0"></iframe>
 * <script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>
 *
 * URL example:
 * https://vine.co/v/bjHh0zHdgZT/
 *
 * Embed shortcode examples:
 * [embed]https://vine.co/v/bjHh0zHdgZT[/embed]
 * [embed width="300"]https://vine.co/v/bjHh0zHdgZT[/embed]
 * [embed type="postcard" width="300"]https://vine.co/v/bjHh0zHdgZT[/embed]
 **/
function vine_embed_video($matches, $attr, $url, $rawattr)
{
    static $vine_flag_embedded_script;
    $max_height = 300;
    $type = 'simple';
    // Only allow 'postcard' or 'simple' types
    if (isset($rawattr['type']) && $rawattr['type'] === 'postcard') {
        $type = 'postcard';
    }
    $vine_size = Jetpack::get_content_width();
    // If the user enters a value for width or height, we ignore the Jetpack::get_content_width()
    if (isset($rawattr['width']) || isset($rawattr['height'])) {
        // 300 is the minimum size that Vine provides for embeds. Lower than that, the postcard embeds looks weird.
        $vine_size = max($max_height, min($attr['width'], $attr['height']));
    }
    if (empty($vine_size)) {
        $vine_size = $max_height;
    }
    $url = 'https://vine.co/v/' . $matches[1] . '/embed/' . $type;
    $vine_html = sprintf('<span class="embed-vine" style="display: block;"><iframe class="vine-embed" src="%s" width="%s" height="%s" frameborder="0"></iframe></span>', esc_url($url), (int) $vine_size, (int) $vine_size);
    if ($vine_flag_embedded_script !== true) {
        $vine_html .= '<script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>';
        $vine_flag_embedded_script = true;
    }
    return $vine_html;
}
开发者ID:valiror,项目名称:sharingdais_demo1,代码行数:39,代码来源:vine.php

示例2: filter_the_content

 /**
  * Identify images in post content, and if images are local (uploaded to the current site), pass through Photon.
  *
  * @param string $content
  * @uses self::validate_image_url, apply_filters, jetpack_photon_url, esc_url
  * @filter the_content
  * @return string
  */
 public static function filter_the_content($content)
 {
     $images = Jetpack_Photon::parse_images_from_html($content);
     if (!empty($images)) {
         $content_width = Jetpack::get_content_width();
         $image_sizes = self::image_sizes();
         $upload_dir = wp_upload_dir();
         foreach ($images[0] as $index => $tag) {
             // Default to resize, though fit may be used in certain cases where a dimension cannot be ascertained
             $transform = 'resize';
             // Start with a clean attachment ID each time
             $attachment_id = false;
             // Flag if we need to munge a fullsize URL
             $fullsize_url = false;
             // Identify image source
             $src = $src_orig = $images['img_url'][$index];
             /**
              * Allow specific images to be skipped by Photon.
              *
              * @module photon
              *
              * @since 2.0.3
              *
              * @param bool false Should Photon ignore this image. Default to false.
              * @param string $src Image URL.
              * @param string $tag Image Tag (Image HTML output).
              */
             if (apply_filters('jetpack_photon_skip_image', false, $src, $tag)) {
                 continue;
             }
             // Support Automattic's Lazy Load plugin
             // Can't modify $tag yet as we need unadulterated version later
             if (preg_match('#data-lazy-src=["|\'](.+?)["|\']#i', $images['img_tag'][$index], $lazy_load_src)) {
                 $placeholder_src = $placeholder_src_orig = $src;
                 $src = $src_orig = $lazy_load_src[1];
             } elseif (preg_match('#data-lazy-original=["|\'](.+?)["|\']#i', $images['img_tag'][$index], $lazy_load_src)) {
                 $placeholder_src = $placeholder_src_orig = $src;
                 $src = $src_orig = $lazy_load_src[1];
             }
             // Check if image URL should be used with Photon
             if (self::validate_image_url($src)) {
                 // Find the width and height attributes
                 $width = $height = false;
                 // First, check the image tag
                 if (preg_match('#width=["|\']?([\\d%]+)["|\']?#i', $images['img_tag'][$index], $width_string)) {
                     $width = $width_string[1];
                 }
                 if (preg_match('#height=["|\']?([\\d%]+)["|\']?#i', $images['img_tag'][$index], $height_string)) {
                     $height = $height_string[1];
                 }
                 // Can't pass both a relative width and height, so unset the height in favor of not breaking the horizontal layout.
                 if (false !== strpos($width, '%') && false !== strpos($height, '%')) {
                     $width = $height = false;
                 }
                 // Detect WP registered image size from HTML class
                 if (preg_match('#class=["|\']?[^"\']*size-([^"\'\\s]+)[^"\']*["|\']?#i', $images['img_tag'][$index], $size)) {
                     $size = array_pop($size);
                     if (false === $width && false === $height && 'full' != $size && array_key_exists($size, $image_sizes)) {
                         $width = (int) $image_sizes[$size]['width'];
                         $height = (int) $image_sizes[$size]['height'];
                         $transform = $image_sizes[$size]['crop'] ? 'resize' : 'fit';
                     }
                 } else {
                     unset($size);
                 }
                 // WP Attachment ID, if uploaded to this site
                 if (preg_match('#class=["|\']?[^"\']*wp-image-([\\d]+)[^"\']*["|\']?#i', $images['img_tag'][$index], $attachment_id) && (0 === strpos($src, $upload_dir['baseurl']) || apply_filters('jetpack_photon_image_is_local', false, compact('src', 'tag', 'images', 'index')))) {
                     $attachment_id = intval(array_pop($attachment_id));
                     if ($attachment_id) {
                         $attachment = get_post($attachment_id);
                         // Basic check on returned post object
                         if (is_object($attachment) && !is_wp_error($attachment) && 'attachment' == $attachment->post_type) {
                             $src_per_wp = wp_get_attachment_image_src($attachment_id, isset($size) ? $size : 'full');
                             if (self::validate_image_url($src_per_wp[0])) {
                                 $src = $src_per_wp[0];
                                 $fullsize_url = true;
                                 // Prevent image distortion if a detected dimension exceeds the image's natural dimensions
                                 if (false !== $width && $width > $src_per_wp[1] || false !== $height && $height > $src_per_wp[2]) {
                                     $width = false == $width ? false : min($width, $src_per_wp[1]);
                                     $height = false == $height ? false : min($height, $src_per_wp[2]);
                                 }
                                 // If no width and height are found, max out at source image's natural dimensions
                                 // Otherwise, respect registered image sizes' cropping setting
                                 if (false == $width && false == $height) {
                                     $width = $src_per_wp[1];
                                     $height = $src_per_wp[2];
                                     $transform = 'fit';
                                 } elseif (isset($size) && array_key_exists($size, $image_sizes) && isset($image_sizes[$size]['crop'])) {
                                     $transform = (bool) $image_sizes[$size]['crop'] ? 'resize' : 'fit';
                                 }
                             }
                         } else {
//.........这里部分代码省略.........
开发者ID:rbryerking,项目名称:skillcrush-wordpress,代码行数:101,代码来源:class.photon.php

示例3: is_wide_theme

 public function is_wide_theme()
 {
     return Jetpack::get_content_width() > 1000;
 }
开发者ID:ugurozer,项目名称:little,代码行数:4,代码来源:tiled-gallery.php

示例4: editor_max_image_size

 /**
  * When on the edit screen, make sure the custom content width
  * setting is applied to the large image size.
  */
 static function editor_max_image_size($dims, $size = 'medium', $context = null)
 {
     list($width, $height) = $dims;
     if ('large' == $size && 'edit' == $context) {
         $width = Jetpack::get_content_width();
     }
     return array($width, $height);
 }
开发者ID:pcuervo,项目名称:wp-carnival,代码行数:12,代码来源:custom-css.php

示例5: filter_sizes

 /**
  * Filters an array of image `sizes` values, using $content_width instead of image's full size.
  *
  * @since 4.0.4
  * @since 4.1.0 Returns early for images not within the_content.
  * @param array $sizes An array of media query breakpoints.
  * @param array $size  Width and height of the image
  * @uses Jetpack::get_content_width
  * @return array An array of media query breakpoints.
  */
 public function filter_sizes($sizes, $size)
 {
     if (!doing_filter('the_content')) {
         return $sizes;
     }
     $content_width = Jetpack::get_content_width();
     if (!$content_width) {
         $content_width = 1000;
     }
     if (is_array($size) && $size[0] < $content_width) {
         return $sizes;
     }
     return sprintf('(max-width: %1$dpx) 100vw, %1$dpx', $content_width);
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:24,代码来源:class.photon.php

示例6: get_content_width

 public static function get_content_width()
 {
     $tiled_gallery_content_width = Jetpack::get_content_width();
     if (!$tiled_gallery_content_width) {
         $tiled_gallery_content_width = 500;
     }
     return apply_filters('tiled_gallery_content_width', $tiled_gallery_content_width);
 }
开发者ID:shazadmaved,项目名称:vizblog,代码行数:8,代码来源:tiled-gallery.php

示例7: get_content_width

 public static function get_content_width()
 {
     $tiled_gallery_content_width = Jetpack::get_content_width();
     if (!$tiled_gallery_content_width) {
         $tiled_gallery_content_width = 500;
     }
     /**
      * Filter overwriting the default content width.
      *
      * @module tiled-gallery
      *
      * @since 2.1.0
      *
      * @param string $tiled_gallery_content_width Default Tiled Gallery content width.
      */
     return apply_filters('tiled_gallery_content_width', $tiled_gallery_content_width);
 }
开发者ID:spielhoelle,项目名称:amnesty,代码行数:17,代码来源:tiled-gallery.php

示例8: set_content_width

 /**
  * Currently this filter function gets called on
  * 'template_redirect' action and
  * 'admin_init' action
  */
 static function set_content_width()
 {
     // Don't apply this filter on the Edit CSS page.
     if (isset($_GET['page']) && 'editcss' === $_GET['page'] && is_admin()) {
         return;
     }
     $GLOBALS['content_width'] = Jetpack::get_content_width();
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:13,代码来源:custom-css-4.7.php


注:本文中的Jetpack::get_content_width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。