本文整理汇总了PHP中IOHelper::isFileEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP IOHelper::isFileEmpty方法的具体用法?PHP IOHelper::isFileEmpty怎么用?PHP IOHelper::isFileEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOHelper
的用法示例。
在下文中一共展示了IOHelper::isFileEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isEmpty
/**
* @return bool
*/
public function isEmpty()
{
if (!$this->_isEmpty) {
$this->_isEmpty = IOHelper::isFileEmpty($this->getRealPath());
}
return $this->_isEmpty;
}
示例2: _importFeaturedImage
/**
* Import Featured Image from Posts
*
* @param mixed $settings Array of settings
* @param string $postUrl Url of WordPress post
* @param string $baseUrl domain and uri path to Wordpress site
*
* @return string $postContent Post content with image url attributes updated.
*/
private function _importFeaturedImage($settings, $postUrl, $baseUrl)
{
// Scrape post for featured image
$tempFileName = md5($postUrl) . '.tmp';
$tempFolder = craft()->path->getStoragePath() . 'instablog/';
$tempFile = $tempFolder . $tempFileName;
$postUrl = $this->_getAbsoluteUrl($postUrl, $baseUrl);
$curlResponse = $this->_getRemoteFile($postUrl, $tempFile);
$remoteImagePath = false;
if ($curlResponse && false === IOHelper::isFileEmpty($tempFile, true)) {
$dom = new \domDocument();
// load the html into the object
$dom->loadHTMLFile($tempFile);
$dom->preserveWhiteSpace = false;
$imgEls = $dom->getElementsByTagName('img');
foreach ($imgEls as $img) {
if (strpos($img->getAttribute('class'), 'wp-post-image')) {
$remoteImagePath = $img->getAttribute('src');
}
}
IOHelper::deleteFile($tempFile, true);
}
// Add asset
if ($remoteImagePath) {
if ($assetId = $this->_addAsset($settings, $remoteImagePath, $baseUrl, false)) {
return $assetId;
}
}
return false;
}