{"id":5122849,"date":"2014-07-23T09:56:46","date_gmt":"2014-07-23T09:56:46","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/adding-alt-or-title-text-to-fancybox\/"},"modified":"2016-08-21T23:32:04","modified_gmt":"2016-08-21T23:32:04","slug":"adding-alt-or-title-text-to-fancybox","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/adding-alt-or-title-text-to-fancybox\/","title":{"rendered":"Adding Alt or Title text to Fancybox"},"content":{"rendered":"<p>Hi<\/p>\n<p>I posted this in the main how to and troubleshooting forum but got not answer so thought I&#8217;d come ask the main man himself.<\/p>\n<p>I&#8217;m using lightbox as a gallery. It&#8217;s customised a bit so when you click on a thumbnail, it opens Fancybox and you can scroll through the images in the gallery.<\/p>\n<p>It was done using this tutorial<\/p>\n<p>http:\/\/www.bentedder.com\/nextgen-gallery-load-lightbox-gallery-from-one-image\/<\/p>\n<p><iframe loading=\"lazy\" title=\"WordPress + Nextgen Gallery: Load Lightbox Gallery From One Image\" width=\"500\" height=\"375\" src=\"https:\/\/www.youtube.com\/embed\/6m71kfYXnDY?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/p>\n<p>And this is the code from it<\/p>\n<pre><code>&lt;?php\n\/**\nTemplate Page for the gallery overview\n\nFollow variables are useable :\n\n    $gallery     : Contain all about the gallery\n    $images      : Contain all images, path, title\n    $pagination  : Contain the pagination content\n\n You can check the content when you insert the tag &lt;?php var_dump($variable) ?&gt;\n If you would like to show the timestamp of the image ,you can use &lt;?php echo $exif[&#039;created_timestamp&#039;] ?&gt;\n**\/\n?&gt;\n&lt;?php if (!defined (&#039;ABSPATH&#039;)) die (&#039;No direct access allowed&#039;); ?&gt;\n&lt;?php if (!empty ($gallery)) : ?&gt;\n\n&lt;?php $i=1; ?&gt;\n\n&lt;div class=&quot;gallery-holder gal&lt;?php echo $gallery-&gt;ID; ?&gt;&quot;&gt;\n&lt;?php foreach ($images as $image) : ?&gt;\n\n    &lt;?php if ($i &lt; 2) : ?&gt;\n        &lt;div style=&quot;display:none;&quot;&gt;\n            &lt;img src=&quot;&lt;?php echo $image-&gt;imageURL ?&gt;&quot; \/&gt;\n        &lt;\/div&gt;\n        &lt;a href=&quot;&lt;?php echo $image-&gt;imageURL ?&gt;&quot; &lt;?php echo $image-&gt;thumbcode ?&gt; title=&quot;&lt;?php echo $gallery-&gt;title ?&gt;&quot;&gt;\n            &lt;img src=&quot;&lt;?php echo $image-&gt;thumbnailURL ?&gt;&quot; \/&gt;&lt;\/a&gt;\n    &lt;?php else : ?&gt;\n        &lt;a style=&quot;display:none&quot; href=&quot;&lt;?php echo $image-&gt;imageURL ?&gt;&quot; &lt;?php echo $image-&gt;thumbcode ?&gt;&gt;link&lt;\/a&gt;\n&lt;?php endif; $i++; ?&gt;\n\n&lt;?php endforeach; ?&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<p>If I change out the line<\/p>\n<p><code>&lt;a href=&quot;&lt;?php echo $image-&gt;imageURL ?&gt;&quot; &lt;?php echo $image-&gt;thumbcode ?&gt; title=&quot;&lt;?php echo $gallery-&gt;title ?&gt;&quot;&gt;<\/code><\/p>\n<p>for<\/p>\n<p><code>&lt;a href=&quot;&lt;?php echo $image-&gt;imageURL ?&gt;&quot; title=&quot;&lt;?php echo $image-&gt;alttext ?&gt;&quot; &lt;?php echo $image-&gt;thumbcode ?&gt; &gt;<\/code><\/p>\n<p>But then it only displays the alt text\/title for the first image in the gallery. I guess it needs some sort of loop to make it work for every image but my PHP knowledge is very limited.<\/p>\n<p>Got any ideas?<\/p>\n<p>Thanks<\/p>\n<p>Josh<\/p>\n<p>https:\/\/wordpress.org\/plugins\/nextgen-gallery\/<\/p>\n","protected":false},"template":"","class_list":["post-5122849","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5122849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5122849\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=5122849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}