I do not advocate doing this unless you manage your site yourself... if working for a client you probably shouldnt do this until the module does it "properly".... some might argue that since the functionality is there, its "proper"....
You can get both alt and title with the below code. I tested it and it works. If alt is left blank, GF happily inserts the image name.
hmmmm.... a hyperlink or button could also be generated... go to product page... add to cart or add to lightbox etc etc.....;)
This is from the 7,x-1.x-dev version of the module. In galleryformatter.tpl.php template... around line 24:
<div class="gallery-frame">
<ul>
<?php foreach ($slides as $id => $data): ?>
<li class="gallery-slide" id="<?php print $data['hash_id']; ?>">
<?php print $data['image']; ?>
<?php if (!empty($data['title'])): ?>
<div class="panel-overlay">
<div class="overlay-inner">
<?php if ($data['alt']): ?><h3><?php print $data['alt']; ?></h3><?php endif; ?>
<?php if ($data['title']): ?><h3><?php print $data['title']; ?></h3><?php endif; ?>
</div>
</div>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
Again, to me the module needs more code to accommodate this properly so I do not advocate this except for testing or short term purposes.
If you decide to go this route, be sure to backup your template file first.
I have a couple other items for a patch in the works and will also try to incorporate the beginnings of "proper" code for this behavior (unless Manuel thinks it is okay to use it like the above test example) :)
| Comment | File | Size | Author |
|---|---|---|---|
| screen-cap-without-alt.png | 346.34 KB | DRIVE | |
| screen-cap-with-alt.png | 288.41 KB | DRIVE |
Comments
Comment #1
Sameo commentedWorks even better.
Comment #2
Aamuktha commentedYes,I too used this method.It works fine.
Comment #3
manuel garcia commentedThanks for the report. We were not printing the alt text in the tpl file, although processed to be available to the tpl....
I've committed the fix already, and will be included in the next release.
Comment #4
turboflash commentedIs there a possibility to include an option to disable the display of ALT attribute? I was quite surprised to see my ALT text appearing when I upgraded the module and my ALT text is quite descriptive. I have to "hack" the module by removing the code manually from the tpl file.
Comment #5
nevets commentedThe alt tag if used really should be part of the img tag.
Comment #6
manuel garcia commentedPlease dont hijack other issues for your own porpsues.