MediaItemModule::setImageIf PHP Метод

setImageIf() публичный Метод

Sets the image if it satisfies the $isAllowed condition. The function DOES NOT handle the url()-ing.
public setImageIf ( boolean | string | array $isAllowed, string $source = '', string $url = '', string $cssClass = '', string $alt = '' ) : MediaItemModule
$isAllowed boolean | string | array Either a boolean to indicate whether to actually add the item or a permission string or array of permission strings (full match) to check.
$source string The image source url. The function DOES NOT handle the url()-ing.
$url string The image anchor link, if the image is an anchor. The function DOES NOT handle the url()-ing.
$cssClass string The CSS class for the image.
$alt string The image alt.
Результат MediaItemModule $this
    public function setImageIf($isAllowed, $source = '', $url = '', $cssClass = '', $alt = '')
    {
        if (!$this->allowed($isAllowed)) {
            return $this;
        }
        return $this->setImage($source, $url, $cssClass, $alt);
    }