當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TimberURLHelper::get_rel_path方法代碼示例

本文整理匯總了PHP中TimberURLHelper::get_rel_path方法的典型用法代碼示例。如果您正苦於以下問題:PHP TimberURLHelper::get_rel_path方法的具體用法?PHP TimberURLHelper::get_rel_path怎麽用?PHP TimberURLHelper::get_rel_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TimberURLHelper的用法示例。


在下文中一共展示了TimberURLHelper::get_rel_path方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sideload_image

 /**
  * downloads an external image to the server and stores it on the server
  *
  * @param string  $file the URL to the original file
  * @return string the URL to the downloaded file
  */
 public static function sideload_image($file)
 {
     $loc = self::get_sideloaded_file_loc($file);
     if (file_exists($loc)) {
         return TimberURLHelper::preslashit(TimberURLHelper::get_rel_path($loc));
     }
     // Download file to temp location
     if (!function_exists('download_url')) {
         require_once ABSPATH . '/wp-admin/includes/file.php';
     }
     $tmp = download_url($file);
     preg_match('/[^\\?]+\\.(jpe?g|jpe|gif|png)\\b/i', $file, $matches);
     $file_array = array();
     $file_array['name'] = basename($matches[0]);
     $file_array['tmp_name'] = $tmp;
     // If error storing temporarily, unlink
     if (is_wp_error($tmp)) {
         @unlink($file_array['tmp_name']);
         $file_array['tmp_name'] = '';
     }
     // do the validation and storage stuff
     $locinfo = pathinfo($loc);
     $file = wp_upload_bits($locinfo['basename'], null, file_get_contents($file_array['tmp_name']));
     return $file['url'];
 }
開發者ID:Butterwell,項目名稱:timber,代碼行數:31,代碼來源:timber-image-helper.php

示例2: testInitFromURL

 function testInitFromURL()
 {
     $destination_path = self::copyTestImage();
     $destination_path = TimberURLHelper::get_rel_path($destination_path);
     $destination_url = 'http://' . $_SERVER['HTTP_HOST'] . $destination_path;
     $image = new TimberImage($destination_url);
     $this->assertEquals($destination_url, $image->get_src());
     $this->assertEquals($destination_url, (string) $image);
 }
開發者ID:aauroux,項目名稱:timber,代碼行數:9,代碼來源:test-timber-image.php

示例3: testImageWidthWithFilter

 function testImageWidthWithFilter()
 {
     $pid = $this->factory->post->create();
     $photo = $this->copyTestImage();
     $photo = TimberURLHelper::get_rel_path($photo);
     update_post_meta($pid, 'custom_photo', '/' . $photo);
     $str = '{{TimberImage(post.custom_photo).width}}';
     $post = new TimberPost($pid);
     $rendered = Timber::compile_string($str, array('post' => $post));
     $this->assertEquals(1500, $rendered);
 }
開發者ID:rpkoller,項目名稱:timber,代碼行數:11,代碼來源:test-timber-image.php

示例4: get_rel_path

 /**
  * @deprecated
  */
 static function get_rel_path($src)
 {
     return TimberURLHelper::get_rel_path($src);
 }
開發者ID:aauroux,項目名稱:timber,代碼行數:7,代碼來源:timber-helper.php

示例5: path

 /**
  * @api
  * @example
  * ```twig
  * <img src="{{ image.path }}" />
  * ```
  * ```html
  * <img src="/wp-content/uploads/2015/08/pic.jpg" />
  * ```
  * @return  string the /relative/path/to/the/file
  */
 public function path()
 {
     return TimberURLHelper::get_rel_path($this->src());
 }
開發者ID:o2themar,項目名稱:wordpress_site,代碼行數:15,代碼來源:timber-image.php


注:本文中的TimberURLHelper::get_rel_path方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。