I've created a site using concrete5 5.6.3.2. I've used the code in this thread to try and help my thumb nail cached images have a more seo friendly look, line 36 highlighted.
https://www.concrete5.org/index.php?cID=540812&editmode=
After I put the file into my root helpers folder, on one of my blog posts thumbnail images, I see this error instead of the thumbnail:
Warning: preg_replace(): Unknown modifier 'h' in /home/foundry/public_html/helpers/image.php on line 36
I've since created a new blog and the thumbnail does not have the same issue.
This is what my root/helpers/image.php code looks like, line 36 in bold:
defined('C5_EXECUTE') or die("Access Denied.");
class ImageHelper extends Concrete5_Helper_Image {public function getThumbnail($obj, $maxWidth, $maxHeight, $crop = false) { $fID = false; if ($obj instanceof File) { $path = $obj->getPath(); $fID = $obj->getFileID(); } else { $path = $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;
}
}}
The site page link is http://www.pentictonfoundry.com/news/
Thanks to anyone for feedback on this, I greatly appreciate it!