Skip to content

Commit

Permalink
add new logic to get correct carousel image in content.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleemy1997 committed Apr 17, 2018
1 parent a7717e4 commit 951ccdd
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion widgets/DbCarousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,33 @@ public function init()
foreach ($query->all() as $k => $item) {
/** @var $item \centigen\i18ncontent\models\WidgetCarouselItem */
$carouselItem = [];
$carouselItem['content'] = Html::img($item->getImageUrl() , $this->imgOptions);
if ($item->getImageUrl() && $item->getImageMobileUrl()) {
$tmpOptionsDesktop = $this->imgOptions;
$class = " carouselImgDesktop";
if (!isset($tmpOptionsDesktop['class'])) {
$tmpOptionsDesktop['class'] = $class;
} else {
$tmpOptionsDesktop['class'] .= $class;
}

$imgDesktop = Html::img($item->getImageUrl(), $tmpOptionsDesktop);


$tmpOptionsMobile = $this->imgOptions;
$class = " carouselImgMobile";
if (!isset($tmpOptionsMobile['class'])) {
$tmpOptionsMobile['class'] = $class;
} else {
$tmpOptionsMobile['class'] .= $class;
}
$imgMobile = Html::img($item->getImageMobileUrl(), $tmpOptionsMobile);

$carouselItem['content'] = $imgDesktop . $imgMobile;
} else {
$carouselItem['content'] = Html::img($item->getImageUrl(), $this->imgOptions);

}


if ($item->url) {
$carouselItem['content'] = Html::a($carouselItem['content'], $item->url, ['target' => '_blank']);
Expand Down

0 comments on commit 951ccdd

Please sign in to comment.