Permalink
Browse files

Fixes #420 Photo thumbnail creation missing on certain servers with r…

…outing
  • Loading branch information...
1 parent 507b3f7 commit fff8dec13da00e9aa6a11143c13af4f7a794c56b Kris Thom White committed Aug 6, 2012
@@ -109,7 +109,7 @@ public static function GetImageLink($intRowid,
return Images::GetImageUri($objImage->ImagePath);
$strType = ImagesType::ToString($intType);
- return "index.php?$strType=$intRowid";
+ return _xls_site_url("ctn/photo?$strType=$intRowid");
}
// LEGACY
@@ -190,7 +190,7 @@ public function IsPrimary() {
public function GetLink() {
if ($this->ImageFileExists())
return Images::GetImageUri($this->ImagePath);
- return "index.php?image=$this->intRowid";
+ return _xls_site_url("ctn/photo?image=$this->intRowid");
}
public function GetPath() {
@@ -45,6 +45,7 @@ class XLSURL {
const KEY_PAGE = "pg"; //formerly anything that was xlspg=
const KEY_SEARCH = "search";
const KEY_IMAGE = "img";
+ const KEY_PHOTO = "photo";
protected $strUri; //URL before parsing
protected $strRouteCode; //p for product, c for category, checkout for checkout, etc. can be customized
@@ -160,8 +161,13 @@ protected function SetRouting() {
$this->strRouteController = "searchresults";
$this->intStatus=200;
break;
+
+ case XLSURL::KEY_PHOTO: //Photo url to trigger thumbnail creation
+ $this->strRouteController = "photo";
+ $this->intStatus=200;
+ break;
- default:
+ default:
$this->strRouteId = $this->arrUrlSegments[0];
if (empty($this->strRouteId)) {
$objCp = CustomPage::LoadByKey('index');
@@ -52,7 +52,9 @@ public function doShow($prod , $imageid = false){
else
$this->current_image = $prod->ImageId;
- $this->pnlImage->Text = '<img src="index.php?image=' . $this->current_image . '" alt="" class="" />';
+ $this->pnlImage->Text = '<img src="'._xls_site_url('ctn/photo?image=' . $this->current_image) . '"
+ alt="" class=""
+ />';
$img = Images::Load($this->current_image);
View
@@ -109,6 +109,10 @@
case 'xlspg':
$strFile = $objUrl->RouteId.".php";
break;
+
+ case 'photo': //only when thumbnail is missing
+ //do not set $strFile so we skip down to images
+ break;
}
@@ -132,35 +136,36 @@
}
}
+if ($objUrl->RouteController=="photo") {
+ //If we are directly trying to get photos, process those here.
+ foreach (ImagesType::$NameArray as $strType) {
+ if (!isset($_GET[$strType]))
+ continue;
-//If we are directly trying to get photos, process those here.
-foreach (ImagesType::$NameArray as $strType) {
- if (!isset($_GET[$strType]))
- continue;
+ $intType = ImagesType::ToToken($strType);
- $intType = ImagesType::ToToken($strType);
+ $imgid = $_GET[$strType];
+ $imgid = trim($imgid);
- $imgid = $_GET[$strType];
- $imgid = trim($imgid);
+ if (!empty($imgid))
+ $img = Images::Load($imgid);
- if (!empty($imgid))
- $img = Images::Load($imgid);
+ if (!$img) {
+ $img = new Images();
+ if ($intType == ImagesType::normal)
+ $img->Width = $img->Height = 256;
+ }
- if (!$img) {
- $img = new Images();
- if ($intType == ImagesType::normal)
- $img->Width = $img->Height = 256;
- }
+ if ($intType == ImagesType::normal) {
+ $img->Show();
+ exit;
+ }
- if ($intType == ImagesType::normal) {
- $img->Show();
- exit;
- }
+ list($intWidth, $intHeight) = ImagesType::GetSize($intType);
+ $img->ShowThumb($intWidth, $intHeight);
- list($intWidth, $intHeight) = ImagesType::GetSize($intType);
- $img->ShowThumb($intWidth, $intHeight);
-
- break;
+ break;
+ }
}

0 comments on commit fff8dec

Please sign in to comment.