emo Group Images for Lightbox

More
10 years 11 months ago #687

Thank you. The Data-Group is now added to the Class of the <a> Tag, but
unfortunatly the Javascript is not working anymore thor those Images.
So I changed

$html .= '<a href="'.$this->info->original->url.'" class="'.$class.' zoomin magnific-popup-'.$this->plugin->item->id.'" style="'.$this->linkStyle.'" title="'.$this->image->getAttribute('alt').'">';
to
if ($this->image->getAttribute('data-group') == '') {
		$groupId = $this->plugin->item->id;
	}
	else {
		$groupId = $this->image->getAttribute('data-group');
	}
    $html  .= '<a href="'.$this->info->original->url.'" class="'.$class.' zoomin magnific-popup-'.$groupId.'" style="'.$this->linkStyle.'" title="'.$this->image->getAttribute('alt').'">';

Looking at your Code at DecoratorMagnific.php, I might have to change something there as well for the Magnific Code to work:
/**
     * Action for each item
     */
    public function item()
    {
        if(!$this->headerAdded) { return; }

        if (!isset($this->plugin->item->id)) {
            $this->plugin->item->id = uniqid();
        }
        $document = \JFactory::getDocument();
		$class = 'magnific-popup-'.$this->plugin->item->id;
		$document->addScriptDeclaration("
            jQuery(document).ready(
                function(){
                    jQuery('.{$class}').magnificPopup({
                        type:'image',
                        gallery: {
                            enabled:true,
                            preload: [1,2]
                        }
                    });
                }
            )
        ");
    }

But changing $class = 'magnific-popup-'.$this->plugin->item->id;
to
if ($this->image->getAttribute('data-group') == '') {
			$class = 'magnific-popup-'.$this->image->getAttribute('data-group');
		}
		else {
			
			$class = 'magnific-popup-'.$this->plugin->item->id;
		}

Results in a Server Error Notice: Undefined property: Plugin\Content\MavikThumbnails\DecoratorMagnific::$image in D:\xampp\htdocs\schoenruh\plugins\content\mavikthumbnails\decorators\popups\magnific\DecoratorMagnific.php on line 57

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago #688

it's ready file

<?php
/**
 * @package Joomla
 * @subpackage mavikThumbnails 2
 * @copyright 2014 Vitaliy Marenkov
 * @author Vitaliy Marenkov <admin@mavik.com.ua>
 * @license GNU General Public License version 2 or later; see LICENSE.txt
 * 
 * Plugin automatic replaces big images to thumbnails.
 */
defined('_JEXEC') or die();

$document = JFactory::getDocument();
$document->addStyleSheet(JUri::base(true).'/media/plg_content_mavikthumbnails/css/mavikthumbnails.css');

$html = '';
$class = $this->image->getAttribute('class') ? $this->image->getAttribute('class').' thumbnail' : 'thumbnail';
$title =  htmlspecialchars($this->image->getAttribute('title'));
$hasCaption = $title && $this->image->hasCaption();
$groupId = $this->image->getAttribute('data-group') ?: $this->plugin->item->id;
$popupClass = 'magnific-group-'.$groupId;

if (!isset($this->plugin->item->popup)) {
    $this->plugin->item->popup = true;    
    $document = \JFactory::getDocument();
    $document->addScriptDeclaration("
        jQuery(document).ready(
            function(){
                jQuery('.{$popupClass}').magnificPopup({
                    type:'image',
                    gallery: {
                        enabled:true,
                        preload: [1,2]
                    }
                });
            }
        )
    ");
}

if ($hasCaption) {
    $html .= "<figure class=\"$class\" style=\"{$this->linkStyle}\">";
    $class = '';
    $this->linkStyle = '';
}
if ($this->isThumbnail) {
    $html .= "<a href=\"{$this->info->original->url}\" class=\"$class $popupClass zoomin\" style=\"{$this->linkStyle}\" title=\"".$this->image->getAttribute('alt').'">';
}
$html .= (string) $this->image;
if ($hasCaption) {
    $html .= "<figcaption>$title</figcaption>";
}
if ($this->isThumbnail) {
    $html .= '</a>';
}
if ($hasCaption) {
    $html .= '</figure>';
}

echo $html;

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago #690

Thank you,

unfortunatly, it only works for the 1st Group. If you have more than 1 Group, the first Image that is processed is where the Jquery Popup Code is generated.

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago #691

I will try fix it.

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago #694

Try it

<?php
/**
 * @package Joomla
 * @subpackage mavikThumbnails 2
 * @copyright 2014 Vitaliy Marenkov
 * @author Vitaliy Marenkov <admin@mavik.com.ua>
 * @license GNU General Public License version 2 or later; see LICENSE.txt
 *
 * Plugin automatic replaces big images to thumbnails.
 */
defined('_JEXEC') or die();

$document = JFactory::getDocument();
$document->addStyleSheet(JUri::base(true).'/media/plg_content_mavikthumbnails/css/mavikthumbnails.css');

$html = '';
$class = $this->image->getAttribute('class') ? $this->image->getAttribute('class').' thumbnail' : 'thumbnail';
$title =  htmlspecialchars($this->image->getAttribute('title'));
$hasCaption = $title && $this->image->hasCaption();
$groupId = $this->image->getAttribute('data-group') ?: $this->plugin->item->id;
$popupClass = 'magnific-group-'.$groupId;

if (!isset($this->plugin->item->popup[$popupClass])) {
    $this->plugin->item->popup[$popupClass] = true;
    $document = \JFactory::getDocument();
    $document->addScriptDeclaration("
        jQuery(document).ready(
            function(){
                jQuery('.{$popupClass}').magnificPopup({
                    type:'image',
                    gallery: {
                        enabled:true,
                        preload: [1,2]
                    }
                });
            }
        )
    ");
}

if ($hasCaption) {
    $html .= "<figure class=\"$class\" style=\"{$this->linkStyle}\">";
    $class = '';
    $this->linkStyle = '';
}
if ($this->isThumbnail) {
    $html .= "<a href=\"{$this->info->original->url}\" class=\"$class $popupClass zoomin\" style=\"{$this->linkStyle}\" title=\"".$this->image->getAttribute('alt').'">';
}
$html .= (string) $this->image;
if ($hasCaption) {
    $html .= "<figcaption>$title</figcaption>";
}
if ($this->isThumbnail) {
    $html .= '</a>';
}
if ($hasCaption) {
    $html .= '</figure>';
}

echo $html;

Please Log in or Create an account to join the conversation.

Time to create page: 0.101 seconds
Powered by Kunena Forum