【发布时间】:2015-05-13 17:25:27
【问题描述】:
我使用concrete5 5.6.3.2 创建了一个站点。我已使用此线程中的代码来尝试帮助我的缩略图缓存图像具有更 seo 友好的外观,第 36 行突出显示。
https://www.concrete5.org/index.php?cID=540812&editmode=
将文件放入我的根 helpers 文件夹后,在我的一篇博文缩略图中,我看到了这个错误而不是缩略图:
警告:preg_replace():第 36 行 /home/foundry/public_html/helpers/image.php 中的未知修饰符“h”
我已经创建了一个新博客,缩略图没有同样的问题。
这是我的 root/helpers/image.php 代码的样子,第 36 行粗体:
defined('C5_EXECUTE') or die("Access Denied.");
类 ImageHelper 扩展 Concrete5_Helper_Image {公共函数 getThumbnail($obj, $maxWidth, $maxHeight, $crop = false) { $fID = 假; if ($obj instanceof 文件) { $path = $obj->getPath(); $fID = $obj->getFileID(); } 别的 { $路径 = $obj; }
/* BEGIN: Updated code */
$fh = Loader::helper('file');
$suffix = $this->jpegCompression; // Add prefix for compression level to serve the properly compressed images
$suffix .= ($crop ? '-1' : '-0'); // Name cropped images different from resized images so they don't get mixed up in the cache
**$origName = strtolower(preg_replace('/_/', '-', preg_replace('/.'.$fh->getExtension($path).'$/', '', substr(strrchr($path, "/"), 1))));**
if (file_exists($path) && $fID) {
$filename = $origName . '-' . $maxWidth . '-' . $maxHeight . '-' . $suffix . '-' . $fID . '.' . $fh->getExtension($path);
} else if (file_exists($path)) {
$filename = $origName . '-' . $maxWidth . '-' . $maxHeight . '-' . $suffix . '-0.' . $fh->getExtension($path);
} else if ($fID) {
$filename = $origName . '-' . $maxWidth . '-' . $maxHeight . '-' . $suffix . '-' . $fID . $fh->getExtension($path);
} else {
$filename = $origName . '-' . $maxWidth . '-' . $maxHeight . '-' . $suffix . '-0.' . $fh->getExtension($path);
}
/* END: Updated code */
if (!file_exists(DIR_FILES_CACHE . '/' . $filename)) {
// create image there
$this->create($path, DIR_FILES_CACHE . '/' . $filename, $maxWidth, $maxHeight, $crop);
}
$src = REL_DIR_FILES_CACHE . '/' . $filename;
$abspath = DIR_FILES_CACHE . '/' . $filename;
$thumb = new stdClass;
if (isset($abspath) && file_exists($abspath)) {
$thumb->src = $src;
$dimensions = getimagesize($abspath);
$thumb->width = $dimensions[0];
$thumb->height = $dimensions[1];
return $thumb;
}
}}
本站页面链接为http://www.pentictonfoundry.com/news/
感谢任何人对此的反馈,我非常感谢!
【问题讨论】:
标签: preg-replace modifier