Skip to content

Commit

Permalink
Fixed issue: Images in theme options completely broken
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Mar 29, 2018
1 parent f8c1d5a commit 9b59a69
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions application/core/LS_Twig_Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ public static function image($sImagePath, $alt = '', $htmlOptions = array( ))
$sUrlImgAsset = self::assetPublish($oTemplate->path.$sImagePath);
}

if (@is_array(getimagesize(Yii::app()->getConfig('rootdir').$sImagePath))) {
$sUrlImgAsset = self::assetPublish($sImagePath);
if (@is_array(getimagesize(Yii::app()->getConfig('rootdir').'/'.$sImagePath))) {
$sUrlImgAsset = self::assetPublish(Yii::app()->getConfig('rootdir').'/'.$sImagePath);
}


Expand All @@ -272,17 +272,17 @@ public static function imageSrc($sImagePath, $default = './files/pattern.png')
{
// Reccurence on templates to find the file
$oTemplate = self::getTemplateForRessource($sImagePath);
$sUrlImgAsset = '';
$sUrlImgAsset = $sImagePath;


if ($oTemplate) {
$sUrlImgAsset = self::assetPublish($oTemplate->path.$sImagePath);
}

if (@is_array(getimagesize(Yii::app()->getConfig('rootdir').$sImagePath))) {
$sUrlImgAsset = self::assetPublish(Yii::app()->getConfig('rootdir').$sImagePath);
if (@is_array(getimagesize(Yii::app()->getConfig('rootdir').'/'.$sImagePath))) {
$sUrlImgAsset = self::assetPublish(Yii::app()->getConfig('rootdir').'/'.$sImagePath);
}

$myTemplateAsset = $sUrlImgAsset;
return $sUrlImgAsset;
}

Expand Down
8 changes: 4 additions & 4 deletions application/models/TemplateConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,17 +603,17 @@ public function getHasOptionPage()
private function _filterImages($file)
{
if(file_exists($this->filesPath.$file['name'])) {
$imagePath = $this->filesPath.$file['name'];
$fileRoot = './files';
$imagePath = $this->filesPath.'/'.$file['name'];
$fileRoot = '/files';
} else {
$imagePath = $this->generalFilesPath.$file['name'] ;
$fileRoot = Yii::app()->getConfig("userthemerooturl").'/generalfiles/';
$fileRoot = Yii::app()->getConfig("userthemerooturl").'/generalfiles';
}


$checkImage = getimagesize($imagePath);
if (!($checkImage === false || !in_array($checkImage[2], [IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_GIF]))) {
return ['filepath' => $fileRoot.$file['name'], 'filename'=>$file['name']];
return ['filepath' => $fileRoot.'/'.$file['name'], 'filepathOptions' => $imagePath ,'filename'=>$file['name']];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<!-- Input -->
<div class="">
<?php
$readonly = $aAttribute['readonly'] || ($aAttribute['readonly_when_active'] && $bIsActive);
$readonly = $aAttribute['readonly'] || (isset($aAttribute['readonly_when_active']) && $aAttribute['readonly_when_active'] && $bIsActive);
switch ($aAttribute['inputtype'])
{
// Switch
Expand Down
2 changes: 1 addition & 1 deletion themes/survey/bootswatch/options/options.twig
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
{% endif %}

{% for image in templateConfiguration.imageFileList %}
<option data-lightbox-src="{{imageSrc(image.filepath)}}" value="{{image.filepath}}">{{image.filename}}</option>
<option data-lightbox-src="{{imageSrc(image.filepathOptions)}}" value="{{image.filepath}}">{{image.filename}}</option>
{% endfor %}
</select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion themes/survey/fruity/options/options.twig
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@
{% endif %}

{% for image in templateConfiguration.imageFileList %}
<option data-lightbox-src="{{imageSrc(image.filepath)}}" value="{{image.filepath}}">{{image.filename}}</option>
<option data-lightbox-src="{{imageSrc(image.filepathOptions)}}" value="{{image.filepath}}">{{image.filename}}</option>
{% endfor %}
</select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion themes/survey/vanilla/options/options.twig
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
{% endif %}

{% for image in templateConfiguration.imageFileList %}
<option data-lightbox-src="{{imageSrc(image.filepath)}}" value="{{image.filepath}}">{{image.filename}}</option>
<option data-lightbox-src="{{imageSrc(image.filepathOptions)}}" value="{{image.filepath}}">{{image.filename}}</option>
{% endfor %}
</select>
</div>
Expand Down

0 comments on commit 9b59a69

Please sign in to comment.