halcyonflow
Forum Replies Created
-
Sorry for all the posts!
Actually
if ($slide['url']doesn’t work for me. Going with
if ($slide['src']Thanks!
PS I found one more post on the above-mentioned thread, for anyone who cares to be reading this:
Replace:
if ($slide['src']with
if ($slide['url']Apparently that’s the correct way to get at the slide link.
That’s all!
PS I found the following workaround here:
Add rel=”lightbox[metaslider_id]
The (currently) last post from Hart has some code that allows me to insert a workaround that does what I want. However, currently that requires me to add his code to my functions.php file, plus an “if” statement for each slide I want to enlarge (I have about 30 portfolio images, so that’s quite a few). I have to manually replace the URL of my slide image, the URL of the “target” (popup) image, and the lightbox group for each instance of this “if” statement.
Here’s the code as per my functions.php file:
add_filter('metaslider_flex_slider_anchor_attributes', 'link_slide_ref_and_a_ref', 10, 3); function link_slide_ref_and_a_ref($anchor_attributes, $slide, $slider_id) { if ($slide['src'] == '/link/to/slide/image.png') { //Link to slide image $anchor_attributes['rel'] = 'lightbox[]'; // Lightbox rel of your image, (using WP Lightbox 2) $anchor_attributes['href'] = '/link/to/target/image.png'; //Link to target popup image } // Repeat above 'if statement' for as many slides as need separate replacement images in a lightbox if ($slide['src'] == '/link/to/slide/image2.png') { $anchor_attributes['rel'] = 'lightbox[]'; $anchor_attributes['href'] = '/link/to/target/image2.png'; } return $anchor_attributes; }It does seem to work, however, so at least I have something for now. Note I’m not an experienced programmer at all, so I imagine there is a more efficient way to do this (maybe a PHP switch statement or something).
Any chance of integrating this as per my suggestion?
Thanks again,
Nick