Was wondering if someone can give me a hand using preg_replace in WordPress to change the way links to images function.
So currently with mootools lazyload enabled I’ve got it spitting out:
<a href='http://localhost:8080/wp-content/uploads/2015/01/2014-11-26-20.52.53.jpg'><img width="150" height="150" src="http://localhost:8080/wp-content/uploads/2015/01/2014-11-26-20.52.53-150x150.jpg" class="attachment-thumbnail" alt="2014-11-26 20.52.53" /></a>
Ideally I’d like it to all thumbnail links load in a Foundation Reveal Modal with code like this:
<a href="#" data-reveal-id="2014-11-26-20.52.53">
<img src="http://localhost:8080/wp-content/uploads/2015/01/2014-11-26-20.52.53-150x150.jpg">
</a>
<div id="2014-11-26-20.52.53" class="reveal-modal" data-reveal>
<img src="http://localhost:8080/wp-content/uploads/2015/01/2014-11-26-20.52.53.jpg">
<a class="close-reveal-modal">×</a>
</div>
Any suggestions? I’ve tried butchering some similar code – but preg_replace isn’t the easiest syntax to learn.
Ok so I’m close:
}
However I’m a bit confused with the $7 variable – I’d like to split this by / and make the filename without the extension the data-reveal-id. Any suggestions?
This worked for me after some minor tweaks for Foundation 6