Jump to content

Textformatter Yumpu Embed


bernhard
 Share

Recommended Posts

very simple module to turn this:

post-2137-0-22966100-1431447994_thumb.pn

into this:

post-2137-0-65991400-1431447995_thumb.pn

<?php

/**
 * ProcessWire Yumpu Replace Textformatter
 *
 * @copyright Copyright (c) 2015, Bernhard Baumrock, dimacon.at
 */

class TextformatterYumpu extends Textformatter
{
    public static function getModuleInfo()
    {
        return array(
            'title'     => 'Yumpu replace',
            'version'   => 1,
            'summary'   => 'Replaces Yumpu Links with responsive Iframes',
            'author'    => 'Bernhard Baumrock, dimacon.at',
        );
    }


    /**
     * Format the input string
     *
     * @param string $str The block of text to parse
     *
     * The incoming string is replaced with the formatted version of itself.
     **/
    public function format(&$str)
    {
        // convert yumpu links to iframes
        $str = preg_replace("/https:\/\/www.yumpu.com\/(..\/)?embed\/view\/\w*/", '<div class="TextformatterVideoEmbed" style="position:relative;padding:30px 0 56.25% 0;height:0;overflow:hidden;"><iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" width="640" height="360" src="\0" frameborder="0" allowfullscreen></iframe></div>', $str);
    }
}

I think there are also other solutions but maybe this one fits better for someone...

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...