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


PHP TimberURLHelper::remove_double_slashes方法代码示例

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


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

示例1: get_retina_file_path

 /**
  * @param string $src
  * @param int $w
  * @param int $h
  * @param string $crop
  * @return string
  */
 static function get_retina_file_path($src, $mult = 2)
 {
     $new_name = self::get_retina_file_name_relative_to_content($src, $mult);
     $new_server_path = WP_CONTENT_DIR . $new_name;
     $new_server_path = TimberURLHelper::remove_double_slashes($new_server_path);
     return $new_server_path;
 }
开发者ID:dleatherman,项目名称:timbangular-js,代码行数:14,代码来源:timber-image-retina-helper.php

示例2: get_rel_url

 /**
  *
  *
  * @param string  $url
  * @param bool    $force
  * @return string
  */
 public static function get_rel_url($url, $force = false)
 {
     $url_info = parse_url($url);
     if (isset($url_info['host']) && $url_info['host'] != self::get_host() && !$force) {
         return $url;
     }
     $link = '';
     if (isset($url_info['path'])) {
         $link = $url_info['path'];
     }
     if (isset($url_info['query']) && strlen($url_info['query'])) {
         $link .= '?' . $url_info['query'];
     }
     if (isset($url_info['fragment']) && strlen($url_info['fragment'])) {
         $link .= '#' . $url_info['fragment'];
     }
     $link = TimberURLHelper::remove_double_slashes($link);
     return $link;
 }
开发者ID:nitwitt10,项目名称:wp-test,代码行数:26,代码来源:timber-url-helper.php

示例3: remove_double_slashes

 /**
  * @deprecated
  */
 static function remove_double_slashes($url)
 {
     return TimberURLHelper::remove_double_slashes($url);
 }
开发者ID:aauroux,项目名称:timber,代码行数:7,代码来源:timber-helper.php

示例4: testResizeGif

 function testResizeGif()
 {
     $filename = self::copyTestImage('loading.gif');
     $gif_url = str_replace(ABSPATH, 'http://' . $_SERVER['HTTP_HOST'] . '/', $filename);
     $str = '<img src="{{' . "'{$gif_url}'" . '|resize(200)}}" />';
     $result = Timber::compile_string($str);
     $resized_url = str_replace('loading.gif', 'loading-200x0-c-default.gif', $gif_url);
     $resized_path = str_replace('http://example.org', ABSPATH, $resized_url);
     $resized_path = TimberURLHelper::remove_double_slashes($resized_path);
     $this->assertFileExists($resized_path);
 }
开发者ID:rpkoller,项目名称:timber,代码行数:11,代码来源:test-timber-image.php

示例5: resize

 /**
  *
  *
  * @param string  $src
  * @param int     $w
  * @param int     $h
  * @param string  $crop
  * @param bool    $force_resize
  * @return string
  */
 public static function resize($src, $w, $h = 0, $crop = 'default', $force_resize = false)
 {
     if (empty($src)) {
         return '';
     }
     if (strstr($src, 'http') && !strstr($src, home_url())) {
         $src = self::sideload_image($src);
     }
     $abs = false;
     if (strstr($src, 'http')) {
         $abs = true;
     }
     // Sanitize crop position
     $allowed_crop_positions = array('default', 'center', 'top', 'bottom', 'left', 'right');
     if ($crop !== false && !in_array($crop, $allowed_crop_positions)) {
         $crop = $allowed_crop_positions[0];
     }
     //oh good, it's a relative image in the uploads folder!
     $new_path = self::get_resize_file_rel($src, $w, $h, $crop);
     $new_server_path = self::get_resize_file_path($src, $w, $h, $crop);
     $old_server_path = self::get_server_location($src);
     $old_server_path = TimberURLHelper::remove_double_slashes($old_server_path);
     $new_server_path = TimberURLHelper::remove_double_slashes($new_server_path);
     if (file_exists($new_server_path)) {
         if ($force_resize) {
             // Force resize - warning: will regenerate the image on every pageload, use for testing purposes only!
             unlink($new_server_path);
         } else {
             if (!$abs) {
                 return TimberURLHelper::preslashit($new_path);
             }
             return untrailingslashit(home_url()) . $new_path;
         }
     }
     $image = wp_get_image_editor($old_server_path);
     if (!is_wp_error($image)) {
         $current_size = $image->get_size();
         $src_w = $current_size['width'];
         $src_h = $current_size['height'];
         $src_ratio = $src_w / $src_h;
         if (!$h) {
             $h = round($w / $src_ratio);
         }
         // Get ratios
         $dest_ratio = $w / $h;
         $src_wt = $src_h * $dest_ratio;
         $src_ht = $src_w / $dest_ratio;
         if (!$crop) {
             // Always crop, to allow resizing upwards
             $image->crop(0, 0, $src_w, $src_h, $w, $h);
         } else {
             //start with defaults:
             $src_x = $src_w / 2 - $src_wt / 2;
             $src_y = ($src_h - $src_ht) / 6;
             //now specific overrides based on options:
             if ($crop == 'center') {
                 // Get source x and y
                 $src_x = round(($src_w - $src_wt) / 2);
                 $src_y = round(($src_h - $src_ht) / 2);
             } else {
                 if ($crop == 'top') {
                     $src_y = 0;
                 } else {
                     if ($crop == 'bottom') {
                         $src_y = $src_h - $src_ht;
                     } else {
                         if ($crop == 'left') {
                             $src_x = 0;
                         } else {
                             if ($crop == 'right') {
                                 $src_x = $src_w - $src_wt;
                             }
                         }
                     }
                 }
             }
             // Crop the image
             if ($dest_ratio > $src_ratio) {
                 $image->crop(0, $src_y, $src_w, $src_ht, $w, $h);
             } else {
                 $image->crop($src_x, 0, $src_wt, $src_h, $w, $h);
             }
         }
         $result = $image->save($new_server_path);
         if (is_wp_error($result)) {
             error_log('Error resizing image');
             error_log(print_r($result, true));
         }
         if ($abs) {
             return untrailingslashit(home_url()) . $new_path;
//.........这里部分代码省略.........
开发者ID:dleatherman,项目名称:timbangular-js,代码行数:101,代码来源:timber-image-helper.php


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