Welcome, Guest
Username: Password: Remember me

TOPIC: Image Caption in Gallery Popup?

Image Caption in Gallery Popup? 2 years 11 months ago #706

  • mavikfan2015
  • mavikfan2015's Avatar
  • Offline
  • Новый участник
  • Posts: 5
  • Thank you received: 1
Hi,

I would like to show captions in the gallery popup (PRO version).

In the popup window for images in an article, the ALT attribute of the image can be used as image caption, but in gallery popups the plugin gets the images from a folder so there is no ALT attribute.

Can mAvik thumbnails show captions in gallery popup?

Thanks!
The administrator has disabled public write access.

Image Caption in Gallery Popup? 2 years 11 months ago #707

  • mavik
  • mavik's Avatar
  • Offline
  • Администратор
  • Posts: 130
  • Thank you received: 22
Hi,

I'm sorry, but not.
But I will try add this function in future versions.
The administrator has disabled public write access.

Image Caption in Gallery Popup? 2 years 11 months ago #708

  • mavikfan2015
  • mavikfan2015's Avatar
  • Offline
  • Новый участник
  • Posts: 5
  • Thank you received: 1
Ok, I will write a code mod so that the gallery can obtain image title and description from IPTC data in the image, and display as caption, similar to ALT attribute for images in articles.

Stand by...
The administrator has disabled public write access.

Image Caption in Gallery Popup? 2 years 11 months ago #711

  • mavikfan2015
  • mavikfan2015's Avatar
  • Offline
  • Новый участник
  • Posts: 5
  • Thank you received: 1
A simple code mod to be able to make gallery pop-up images (PRO version only) display the image IPTC data title and description as a caption.

The good news is: because mAvik Thumbnails is implemented properly according to Joomla design, this can be done as a template override, so you don't need to edit core mAvik code which will get lost on update. Thank you Vitaliiy!

See Joomla Docs (Layout Overrides) for details how to override a plug-in.

Take a copy of
- plugins/content/mavikthumbnails/tmpl/gallery.php
into
- templates/[template]/html/plg_content_mavikthumbnails/

Edit in there:

After
<ul class="gallery">
    <?php foreach ($this->images as $src): ?>
Add
<?php

    $image_local_url = substr ( $src , strpos ( $src , JURI::base() ) + strlen ( JURI::base() ) );

    $iptc_title = '';
    $iptc_description = '';
               
    $size = getimagesize ( $image_local_url, $info );

    if(isset($info['APP13']))
    {

        $iptc = iptcparse($info['APP13']);

        if(is_array($iptc))
        {

            if(isset($iptc["2#005"][0]))
            {
                $iptc_title = htmlentities ( $iptc["2#005"][0] );
            }

            if(isset($iptc["2#120"][0]))
            {
                $iptc_description = htmlentities ( $iptc["2#120"][0] );
            }

        }

    }

    if ( ( $iptc_title !== '' ) && ( $iptc_description !== '' ) )
    {
        $iptc_description = ' - ' . $iptc_description;
    }

?>

Then change
alt=""
to
alt="<?php echo ( $iptc_title . $iptc_description ); ?>"

Note! this cannot handle single-quote characters in the IPTC data - but double-quotes are fine and some other characters.

Note also, your installation may differ in UTF-8 encoding, PHP version etc.
The administrator has disabled public write access.
The following user(s) said Thank You: mavik
Time to create page: 0.325 seconds
Powered by Kunena Forum