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


PHP TimberURLHelper::url_to_file_system方法代码示例

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


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

示例1: testURLToFileSystem

 function testURLToFileSystem()
 {
     $url = 'http://example.org/wp-content/uploads/2012/06/mypic.jpg';
     $file = TimberURLHelper::url_to_file_system($url);
     $this->assertStringStartsWith(ABSPATH, $file);
     $this->assertStringEndsWith('/2012/06/mypic.jpg', $file);
     $this->assertNotContains($file, 'http://example.org');
     $this->assertNotContains($file, '//');
 }
开发者ID:mrgrain,项目名称:timber,代码行数:9,代码来源:test-timber-url-helper.php

示例2: delete_generated_files

 /**
  * Deletes the auto-generated files for resize and letterboxing created by Timber
  * @param string  $local_file   ex: /var/www/wp-content/uploads/2015/my-pic.jpg
  *                              or: http://example.org/wp-content/uploads/2015/my-pic.jpg
  */
 static function delete_generated_files($local_file)
 {
     if (TimberURLHelper::is_absolute($local_file)) {
         $local_file = TimberURLHelper::url_to_file_system($local_file);
     }
     $info = pathinfo($local_file);
     $dir = $info['dirname'];
     $ext = $info['extension'];
     $filename = $info['filename'];
     self::process_delete_generated_files($filename, $ext, $dir, '-[0-9999999]*', '-[0-9]*x[0-9]*-c-[a-z]*.');
     self::process_delete_generated_files($filename, $ext, $dir, '-lbox-[0-9999999]*', '-lbox-[0-9]*x[0-9]*-[a-zA-Z0-9]*.');
 }
开发者ID:Butterwell,项目名称:timber,代码行数:17,代码来源:timber-image-helper.php

示例3: delete_letterboxed_files

 /**
  * Deletes letterboxed versions of the supplied file name
  *
  * @param string  $local_file
  */
 static function delete_letterboxed_files($local_file)
 {
     if (TimberURLHelper::is_absolute($local_file)) {
         $local_file = TimberURLHelper::url_to_file_system($local_file);
     }
     $info = pathinfo($local_file);
     $dir = $info['dirname'];
     $ext = $info['extension'];
     $filename = $info['filename'];
     $searcher = '/' . $filename . '-lbox-[0-9999999]*';
     foreach (glob($dir . $searcher) as $found_file) {
         $regexdir = str_replace('/', '\\/', $dir);
         $pattern = '/' . $regexdir . '\\/' . $filename . '-lbox-[0-9]*x[0-9]*-[a-zA-Z0-9]*.' . $ext . '/';
         $match = preg_match($pattern, $found_file);
         if ($match) {
             unlink($found_file);
         }
     }
 }
开发者ID:Kilbourne,项目名称:restart,代码行数:24,代码来源:timber-image-helper.php

示例4: delete_letterboxed_files_from_url

 static function delete_letterboxed_files_from_url($src)
 {
     $local = TimberURLHelper::url_to_file_system($src);
     self::delete_letterboxed_files($local);
 }
开发者ID:dleatherman,项目名称:timbangular-js,代码行数:5,代码来源:timber-image-helper.php

示例5: init

 /**
  * @param int $iid
  */
 function init($iid = false)
 {
     if (!is_numeric($iid) && is_string($iid)) {
         if (strstr($iid, '://')) {
             $this->init_with_url($iid);
             return;
         }
         if (strstr($iid, ABSPATH)) {
             $this->init_with_file_path($iid);
             return;
         }
         if (strstr(strtolower($iid), '.jpg')) {
             $this->init_with_relative_path($iid);
             return;
         }
     }
     $image_info = $this->get_image_info($iid);
     $this->import($image_info);
     $basedir = self::wp_upload_dir();
     $basedir = $basedir['basedir'];
     if (isset($this->file)) {
         $this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
     } else {
         if (isset($this->_wp_attached_file)) {
             $this->file = reset($this->_wp_attached_file);
             $this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
         } else {
             if (isset($this->guid)) {
                 if (TimberURLHelper::is_absolute($this->guid)) {
                     $this->file_loc = TimberURLHelper::url_to_file_system($this->guid);
                 }
             }
         }
     }
     if (isset($image_info['id'])) {
         $this->ID = $image_info['id'];
     } else {
         if (is_numeric($iid)) {
             $this->ID = $iid;
         }
     }
     if (isset($this->ID)) {
         $custom = get_post_custom($this->ID);
         foreach ($custom as $key => $value) {
             $this->{$key} = $value[0];
         }
     } else {
         if (is_array($iid)) {
             TimberHelper::error_log('Not able to init in TimberImage with iid=');
             TimberHelper::error_log($iid);
         } else {
             TimberHelper::error_log('Not able to init in TimberImage with iid=' . $iid);
         }
     }
 }
开发者ID:Kilbourne,项目名称:restart,代码行数:58,代码来源:timber-image.php


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