Announcement

#1 2013-05-17 21:03:19

jimaek
Member
2013-05-17
41

Use gallery name of the image as alternative text

I use Piwigo 2.5.1 with PHP 5.4.15

My picture_content.tpl contains this code:

<img src="{$current.selected_derivative->get_url()}" {$current.selected_derivative->get_size_htm()} alt="{$ALT_IMG}">

When the image is hovered I want it to display something like:
{GalleryName} Text

How can I do that?

Offline

 

#2 2013-05-18 00:47:44

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Use gallery name of the image as alternative text

use this variable :
{$GALLERY_TITLE}

ps: it's the "title" attribute which need to be assigned

Offline

 

#3 2013-05-18 00:55:07

jimaek
Member
2013-05-17
41

Re: Use gallery name of the image as alternative text

Didnt help.

My code:

<img src="{$current.selected_derivative->get_url()}" {$current.selected_derivative->get_size_htm()} title="{$GALLERY_TITLE}" alt="{$GALLERY_TITLE}">

Output:

<img width="1200" height="2105" alt="" title="" src="../../../_data/i/upload/2013/02/19/37373-me.jpg">

Last edited by jimaek (2013-05-18 00:55:27)

Offline

 

#4 2013-05-18 10:57:48

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Use gallery name of the image as alternative text

well that's unexpected

don't you have a
$conf['gallery_title']
in your local configuration ? (local/config/config.inc.php)

Offline

 

#5 2013-05-18 18:12:38

jimaek
Member
2013-05-17
41

Re: Use gallery name of the image as alternative text

No. config_default.inc.php doesnt have that either.
What I should add?

Offline

 

#6 2013-05-18 18:20:03

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Use gallery name of the image as alternative text

Nothing, the problem would be if you had
$conf['gallery_title'] = '';

can we have the link of your gallery ?

Offline

 

#7 2013-05-18 18:27:23

jimaek
Member
2013-05-17
41

Re: Use gallery name of the image as alternative text

I sent you a PM with the link.

Offline

 

#8 2013-05-18 18:36:00

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Use gallery name of the image as alternative text

well I don't know

your file .../themes/simplengnew/template/picture_content.tpl is good
and the same var is used in ../themes/simplengnew/template/header.tpl successfully

Offline

 

#9 2013-05-18 18:38:52

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Use gallery name of the image as alternative text

Oh I have an idea, try create a personal plugin with this content

Code:

add_event_handler(
  'render_element_content',
  'add_gallery_title_picture_content',
  EVENT_HANDLER_PRIORITY_NEUTRAL-10
);

function add_gallery_title_picture_content($content)
{
  global $template, $page, $conf;

    $template->assign(
      'GALLERY_TITLE',
      isset($page['gallery_title']) ?
        $page['gallery_title'] : $conf['gallery_title']
    );

    return $content;
}

Offline

 

#10 2013-05-18 18:54:38

jimaek
Member
2013-05-17
41

Re: Use gallery name of the image as alternative text

Nice, it works.
But it gives me the title of the website now. But do I make to add the name of the gallery in which the image resides?

Example:

Home/Birds/Big Birds/Picture 1

Picture 1 would have title/alt equal to "Big Birds"

Offline

 

#11 2013-05-18 19:06:14

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Use gallery name of the image as alternative text

ok, we call this an album, not a gallery (the gallery is the whole site)

you can use

Code:

<img src="{$current.selected_derivative->get_url()}" {$current.selected_derivative->get_size_htm()} title="{$SECTION_TITLE|strip_tags} - {$current.TITLE|@replace:'"':' '}" alt="{$ALT_IMG}">

and you don't need the personal plugin anymore

but this displays the full bread crumb

Last edited by mistic100 (2013-05-18 19:07:22)

Offline

 

#12 2013-05-18 19:23:17

jimaek
Member
2013-05-17
41

Re: Use gallery name of the image as alternative text

Can I save the breadcrumb in a variable and do regex on it? And then display the result in the title?
Im still not sure how smarty works.

Offline

 

#13 2013-05-18 19:58:34

jimaek
Member
2013-05-17
41

Re: Use gallery name of the image as alternative text

Ok, trying to do this:

title="{$SECTION_TITLE|strip_tags|regex_replace:"^([^-]*)/ ":" "} - {$current.TITLE|@replace:'"':' '}"

But I get:
Warning:  preg_replace(): Unknown modifier '-' in /home/www/include/smarty/libs/plugins/modifier.regex_replace.php on line 32


According to http://gskinner.com/RegExr/ my regex is correct and works
^([^-]*)/

Offline

 

#14 2013-05-18 20:52:52

jimaek
Member
2013-05-17
41

Re: Use gallery name of the image as alternative text

I did it!

The final code:

<img src="{$current.selected_derivative->get_url()}" {$current.selected_derivative->get_size_htm()} title="{$SECTION_TITLE|strip_tags|regex_replace:'/(.*)\/ /i':''} - {$current.TITLE|@replace:'"':' '}" alt="{$ALT_IMG}">

Thank for the help

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact