Skip to content

Commit

Permalink
Dev: avoid empty values in SRC or URL
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Apr 9, 2019
1 parent 9d1f0eb commit 42c1de6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions application/core/LS_Twig_Extension.php
Expand Up @@ -268,7 +268,7 @@ public static function assetPublish($sRessource)
public static function image($sImagePath, $alt = '', $htmlOptions = array( ))
{
$sUrlImgAsset = self::imageSrc($sImagePath,'');
if(!$sUrlImgAsset) {
if( $sUrlImgAsset === "ERROR") {
return '';
}
return CHtml::image($sUrlImgAsset, $alt, $htmlOptions);
Expand All @@ -292,7 +292,7 @@ public static function imageSrc($sImagePath, $default = false)
if($default) {
return self::imageSrc($default);
}
return false;
return "ERROR";
}
$sFullPath = Yii::app()->getConfig('rootdir').'/'.$sImagePath;
}
Expand All @@ -301,7 +301,7 @@ public static function imageSrc($sImagePath, $default = false)
$checkImage = LSYii_ImageValidator::validateImage($sFullPath);

if (!$checkImage['check']) {
return false;
return "ERROR";
}

$sUrlImgAsset = self::assetPublish($sFullPath);
Expand Down

4 comments on commit 42c1de6

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke API of template.

I already use
{% if (!imageSrc(processString("{TEMPLATEURL}")~"logo.png) %}

What is the issue before ? You return the same string ( "") if imageSrc is invalid …

@LouisGac
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes you're right. I'm going to submit another commit that will not break existing custom themes using "false" value.

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none is better than ERROR , or send a 0 and not false to fix backgound url ?

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another solution : aSurveyInfo.options.backgroundimage check if it's a valid image to set to on ?

Please sign in to comment.