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


PHP TimberURLHelper::is_external_content方法代码示例

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


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

示例1: testSubDirectoryImageLocaion

 function testSubDirectoryImageLocaion()
 {
     if (!is_multisite()) {
         $this->markTestSkipped('Test is only for Multisite');
         return;
     }
     $blog_id = TestTimberMultisite::createSubDirectorySite();
     $this->assertGreaterThan(1, $blog_id);
     $blog_details = get_blog_details($blog_id);
     $pretend_image = 'http://example.org/wp-content/2015/08/fake-pic.jpg';
     $is_external = TimberURLHelper::is_external_content($pretend_image);
     $this->assertFalse($is_external);
 }
开发者ID:Butterwell,项目名称:timber,代码行数:13,代码来源:test-timber-image-multisite.php

示例2: testIsExternalContentMovingFolders

 function testIsExternalContentMovingFolders()
 {
     $internal = 'http://example.org/wp-content/uploads/my-image.png';
     $internal_in_abspath = 'http://example.org/wp/uploads/my-image.png';
     $internal_in_uploads = 'http://example.org/uploads/my-image.png';
     $external = 'http://upstatement.com/my-image.png';
     add_filter('upload_dir', array(&$this, 'mockUploadDir'));
     add_filter('content_url', array(&$this, 'mockContentUrl'));
     $this->mockUploadDir = true;
     $this->assertFalse(TimberURLHelper::is_external_content($internal));
     $this->assertFalse(TimberURLHelper::is_external_content($internal_in_uploads));
     $this->assertFalse(TimberURLHelper::is_external_content($internal_in_abspath));
     $this->assertTrue(TimberURLHelper::is_external_content($external));
     $this->mockUploadDir = false;
 }
开发者ID:mrgrain,项目名称:timber,代码行数:15,代码来源:test-timber-url-helper.php

示例3: _operate

 /**
  * Main method that applies operation to src image:
  * 1. break down supplied URL into components
  * 2. use components to determine result file and URL
  * 3. check if a result file already exists
  * 4. otherwise, delegate to supplied TimberImageOperation
  *
  * @param  string  $src   an URL (absolute or relative) to an image
  * @param  object  $op    object of class TimberImageOperation
  * @param  boolean $force if true, remove any already existing result file and forces file generation
  * @return string         URL to the new image - or the source one if error
  *
  */
 private static function _operate($src, $op, $force = false)
 {
     if (empty($src)) {
         return '';
     }
     // if external image, load it first
     if (TimberURLHelper::is_external_content($src)) {
         $src = self::sideload_image($src);
     }
     // break down URL into components
     $au = self::analyze_url($src);
     // build URL and filenames
     $new_url = self::_get_file_url($au['base'], $au['subdir'], $op->filename($au['filename'], $au['extension']), $au['absolute']);
     $new_server_path = self::_get_file_path($au['base'], $au['subdir'], $op->filename($au['filename'], $au['extension']));
     $old_server_path = self::_get_file_path($au['base'], $au['subdir'], $au['basename']);
     // if already exists...
     if (file_exists($new_server_path)) {
         if ($force) {
             // Force operation - warning: will regenerate the image on every pageload, use for testing purposes only!
             unlink($new_server_path);
         } else {
             // return existing file (caching)
             return $new_url;
         }
     }
     // otherwise generate result file
     if ($op->run($old_server_path, $new_server_path)) {
         return $new_url;
     } else {
         // in case of error, we return source file itself
         return $src;
     }
 }
开发者ID:Butterwell,项目名称:timber,代码行数:46,代码来源:timber-image-helper.php


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