Skip to content

Instantly share code, notes, and snippets.

@ammaridris
Created October 24, 2021 15:46
Show Gist options
  • Save ammaridris/c2800d147d987ea5e9f7bb35e74e9397 to your computer and use it in GitHub Desktop.
Save ammaridris/c2800d147d987ea5e9f7bb35e74e9397 to your computer and use it in GitHub Desktop.
<?php
use Joomla\CMS\Language\Text;
// Config
$config->addAlias('~logo', '~theme.logo');
// Link
$attrs_link = [];
$attrs_link['href'] = $config('~theme.site_url');
$attrs_link['class'][] = isset($class) ? $class : '';
$attrs_link['class'][] = 'uk-logo';
// Logo
$logo_el = Text::_($config('~logo.text'));
$logo_img = function ($image, $width, $height, array $attrs = []) use ($config) {
$attrs['alt'] = Text::_($config('~logo.text'));
$attrs['uk-gif'] = $this->isImage($image) === 'gif';
if ($this->isImage($image) === 'svg') {
return $this->image($image, array_merge($attrs, compact('width', 'height')));
}
return $this->image([$image, 'thumbnail' => [$width, $height], 'srcset' => true], $attrs);
};
// Logo Image
if (isset($mobile)) {
if ($config('~logo.image_mobile')) {
$logo_el = $logo_img($config('~logo.image_mobile'), $config('~logo.image_mobile_width'), $config('~logo.image_mobile_height'));
} elseif ($config('~logo.image')) {
$logo_el = $logo_img($config('~logo.image'), $config('~logo.image_width'), $config('~logo.image_height'));
}
} else {
if ($config('~logo.image')) {
$logo_el = $logo_img($config('~logo.image'), $config('~logo.image_width'), $config('~logo.image_height'));
$lang = JFactory::getLanguage();
if($lang->getTag()=="ms-MY") {
$logo_el = $logo_img($config('~logo.image'), $config('~logo.image_width'), $config('~logo.image_height'));
}
if($lang->getTag()=="en-GB") {
$logo_el = $logo_img($config('~logo.image_inverse'), $config('~logo.image_width'), $config('~logo.image_height'));
}
// Inverse
if ($config('~logo.image_inverse')) {
$logo_el .= $logo_img($config('~logo.image_inverse'), $config('~logo.image_width'), $config('~logo.image_height'), ['class' => ['uk-logo-inverse']]);
}
}
}
?>
<?php if ($logo_el) : ?>
<a<?= $this->attrs($attrs_link) ?>>
<?= $logo_el ?>
</a>
<?php endif ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment