How to automatically insert Lytro Living Pictures into WordPress articles

if you’d like to add lytro living images to your wordpress articles in a fast and easy way, we have a quick and easy solution for you!

how to automatically insert lytro living pictures in wordpress

just open your theme’s functions.php file (if it doesn’t exist, create an empty text file and save it under that filename in your theme folder), and insert the following lines at the end of the file:

//lytro mini-plugin
add_filter('the_content', 'lytroembed');
function lytroembed($content) {
$content = preg_replace('#(?<=[^=\"\'])http[s]?://*)/pictures/([0-9]*)(?=[^/])#','<iframe width="400" height="415" src="\\1/pictures/\\2/embed" frameborder="0" allowfullscreen></iframe>',$content);
return $content;

now, whenever you just copy a living picture’s url to your article, it will be converted to the respective iframe.

if you want your function to be more selective, try adding any code to the first “http” – e.g. “lhttp”, “lttp” or anything else, and it will only convert such URLs in your articles.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.