Lex Sanchez

Module: Video or Social Post Embed

Recommended Posts

Video or Social Post Embed

Based on the TextformatterVideoEmbed module developed by Ryan Cramer, we have added the possibility to embed publications of the main social networks Facebook, Twitter and Instagram.

ProcessWire Textformatter module that enables translation of YouTube, Vimeo, Instagram, Facebook, Twitter or Issuu URLs to full embed codes, resulting in a viewable video or social post in textarea fields you apply it to.

How to install

  • Download or Clone from Github: https://github.com/lexsanchez/VideoOrSocialPostEmbed

  • Copy the VideoOrSocialPostEmbed.module file to your /site/modules/ directory (or place it in /site/modules/VideoOrSocialPostEmbed/).

  • Click check for new modules in ProcessWire Admin Modules screen. Click install for the module labeled: "Video or Social Post Embed".

  • Now you will be on the module config screen. Please make note of the config options and set as you see fit.

How to use

  • Edit your body field in Setup > Fields (or whatever field(s) you will be placing videos in). On the details tab, find the Text Formatters field and select "Video or Social Post Embed". Save.

  • Edit a page using the field you edited and paste in YouTube, Vimeo, Facebook, Twitter, Instagram and/or Issuu URLs each on their own paragraph.

Example

How it might look in your editor (like TinyMCE):

Here are two videos about ProcessWire

http://www.youtube.com/watch?v=Wl4XiYadV_k

http://www.youtube.com/watch?v=XKnG7sikE-U

And here is a great video I watched earlier this week:

http://vimeo.com/18280328

Embed social post and Issuu Presentation:

https://www.instagram.com/p/BeA8p9AhA3b/

https://twitter.com/rpc_radio/status/954315569838411776

https://www.facebook.com/TNTLA/videos/10155549598252758/

https://issuu.com/madsoundsmagazine/docs/mad_sounds_issue_no._17_issuu

How it works

This module uses YouTube, Vimeo, Instagram, Facebook, Twitter and Issuu oEmbed services to generate the embed codes populated in your content. After these services are queried the first time, the embed code is cached so that it doesn't need to be pulled again.

Configuration

You may want to update the max width and max height settings on the module's configuration screen. You should make these consistent with what is supported by your site design.

If you change these max width / max height settings you may also want to check the box to clear cache, so that YouTube/Vimeo/Facebook/Twitter/Instagram/Issuu oembed services will generate new embed codes for you.

Using with Markdown, Textile or other LML

This text formatter is looking for a YouTube, Vimeo, Instagram, Facebook, Twitter or Issuu video URL surrounded by paragraph tags. As a result, if you are using Markdown or Textile (or something else like it) you want that text formatter to run before this one. That ensures that the expected paragraph tags will be present when VideoOrSocialPostEmbed runs. You can control the order that text formatters are run in by drag/drop sorting in the field editor.


Copyright 2018 by Ryan Cramer / Updated by Lex Sanchez

  • Like 18

Share this post


Link to post
Share on other sites

Thank you.

There is a problem here with 

https://www.instagram.com/p/BeA8p9AhA3b/

 

Error: Exception: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'embed_code' at row 1 (in /home/theo/public_html/pwdev/site/modules/VideoOrSocialPostEmbed/TextformatterVideoOrSocialPostEmbed.module line 113)

#0 /home/theo/public_html/pwdev/site/modules/VideoOrSocialPostEmbed/TextformatterVideoOrSocialPostEmbed.module(113): PDOStatement->execute()
#1 /home/theo/public_html/pwdev/site/modules/VideoOrSocialPostEmbed/TextformatterVideoOrSocialPostEmbed.module(337): TextformatterVideoOrSocialPostEmbed->getEmbedCode('://api.instagra...', 'ig-BeA8p9AhA3b')
#2 /home/theo/public_html/pwdev/site/modules/VideoOrSocialPostEmbed/TextformatterVideoOrSocialPostEmbed.module(152): TextformatterVideoOrSocialPostEmbed->embedInstagram('<p>https://www....')
#3 /home/theo/public_html/pwdev/wire/core/Textformatter.php(60): TextformatterVideoOrSocialPostEmbed->format('<p>https://www....


 

Share this post


Link to post
Share on other sites

Hello Theo:

Thanks for your comment; I have made an update to the module that solves this error, please uninstall the module replace with the new version.

Regards,

  • Like 1

Share this post


Link to post
Share on other sites

Thanks, would be interesting to see how your example looks like on the frontend. Maybe you have a screenshot? :)

  • Like 2

Share this post


Link to post
Share on other sites

Hi Bernhard:

Sorry for answering something late, I attached 2 images of how it is shown in social network content.

Captura01.JPG

Captura02.JPG

Captura03.JPG

  • Like 1

Share this post


Link to post
Share on other sites

Is there a way to get this module to work with CKeditor? For me it is not working :( Only the links are visible in frontend.

Share this post


Link to post
Share on other sites

Got it. The URL has to be pain text instead of a link.

Share this post


Link to post
Share on other sites
Posted (edited)

Hello,

When I try to install Video or Social Post Embed in ProcessWire 3.0.102, I have an error page with:

Error

Class '\VideoOrSocialPostEmbed' not found

and

File: /home/********/public_html/wire/core/Modules.php:535

525:                    ProcessWire::setCurrentInstance($wire2);
526:                } else {
527:                    $wire1 = null;
528:                }
529:            } else {
530:                $wire1 = null;
531:                $wire2 = null;
532:            }
533:            
534:            try {
535:                $module = $this->wire(new $className());
536:            } catch(\Exception $e) {
537:                $this->error(sprintf($this->_('Failed to construct module: %s'), $className) . " - " . $e->getMessage());
538:                $module = null;
539:            }

In version 2.8.62, the class wasn't found as well.

If I disable Tracy Debugger, I see:

Fatal error: Uncaught Error: Class '\VideoOrSocialPostEmbed' not found in /home/********/public_html/wire/core/Modules.php:535 Stack trace: #0 /home/********/public_html/wire/core/Modules.php(1704): ProcessWire\Modules->newModule('\\VideoOrSocialP...') #1 /home/********/public_html/wire/core/Wire.php(386): ProcessWire\Modules->___install('VideoOrSocialPo...', Array) #2 /home/********/public_html/wire/core/WireHooks.php(723): ProcessWire\Wire->_callMethod('___install', Array) #3 /home/********/public_html/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Modules), 'install', Array) #4 /home/********/public_html/wire/modules/Process/ProcessModule/ProcessModule.module(262): ProcessWire\Wire->__call('install', Array) #5 /home/********/public_html/wire/core/Wire.php(380): ProcessWire\ProcessModule->___execute() #6 /home/********/public_html/wire/core/WireHooks.php(723): ProcessWire\Wire->_callMethod('___execute', Array) #7 /home/********/public_html/wire/core/Wire.php(442): ProcessWire\WireHooks->runH in /home/********/public_html/wire/core/Modules.php on line 535

and

Error: Uncaught Error: Class '\VideoOrSocialPostEmbed' not found in /home/********/public_html/wire/core/Modules.php:535
Stack trace:
#0 /home/********/public_html/wire/core/Modules.php(1704): ProcessWire\Modules->newModule('\\VideoOrSocialP...')
#1 /home/********/public_html/wire/core/Wire.php(386): ProcessWire\Modules->___install('VideoOrSocialPo...', Array)
#2 /home/********/public_html/wire/core/WireHooks.php(723): ProcessWire\Wire->_callMethod('___install', Array)
#3 /home/********/public_html/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Modules), 'install', Array)
#4 /home/********/public_html/wire/modules/Process/ProcessModule/ProcessModule.module(262): ProcessWire\Wire->__call('install', Array)
#5 /home/********/public_html/wire/core/Wire.php(380): ProcessWire\ProcessModule->___execute()
#6 /home/********/public_html/wire/core/WireHooks.php(723): ProcessWire\Wire->_callMethod('___execute', Array)
#7 /home/********/public_html/wire/core/Wire.php(442): ProcessWire\WireHooks->runH (line 535 of /home/********/public_html/wire/core/Modules.php) 

This error message was shown because: site is in debug mode. ($config->debug = true; => /site/config.php). Error has been logged.

EDIT: I've just been able to install it via the backend (via the .zip URL from GitHub).
I had done it manually before. I had renamed the folder and the .module file VideoOrSocialPostEmbed (like in the documentation(s)). I hadn't done it again without renaming anything (or had I? I don't remember. Perhaps both, or the folder or the file) so I don't know if it was the reason (or one of them).
I've changed the PHP version from 7.1 to 7.2. Not sure it had an effect.

Edited by Christophe
Solved

Share this post


Link to post
Share on other sites

Hello again,

For YouTube videos, would it be possible to make it work with ?rel=0 added at the end of the URL, so that suggestions aren't displayed when pausing or when the video ends.

It works with the Video embed for YouTube and Vimeo module.

Thanks in advance for considering it.

Or if anyone knows how to enable it properly.

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By MoritzLost
      This is a textformatter module that will automatically replace titles of other pages on your site with links to those pages. For example, if you have a template glossary-term, and mention the exact title of one page using that template in a textfield, the title will be automatically linked to that page (if the textfield uses that formatter). This is good for SEO, and saves you some manual labour. You can configure which templates should get automatically linked, and of course the formatter is only active for the fields you add this formatter to. Note that if you need more manual control over when and where titles are automatically linked, you're probably better of using Autolink from a Glossary by @mr-fan.
      Features
      Allows you to limit the automatic links by template. Only includes published & visible pages by default, with an option to include hidden pages. Automatically excludes the current page, with an option to change that behaviour. Supports multi-language sites. Titles will only be linked if a title in the current language is set. Can add configurable CSS classes to all automatically created links. Includes the ability to use page fields as replacement patterns for CSS classes. Queries the database directly for improved performance. Only queries the database once per request & language. Download & Documentation
      The module is now available in the modules directory: https://modules.processwire.com/modules/textformatter-page-title-links/
      You can download & install it through the backend using the classname TextformatterPageTitleLinks.
      To install it manually, download or clone the module from the Github repository into your site/modules folder and install through the backend.
      The complete documentation can be found in the README in the repository. Make sure to check out the module configuration page after installing the module.
      Requirements
      PHP 7.1 or higher ProcessWire 3+ (it will probably work in older versions, I haven't tested those though). This is my first module, I hope it may become useful to some of you 🙂
      If you find any errors or have some other suggestions or feedback, let me know!
    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By horst
      Croppable Image 3
      for PW 3.0.20+
      Module Version 1.1.16
      Sponsored by http://dreikon.de/, many thanks Timo & Niko!
      You can get it in the modules directory!
      Please refer to the readme on github for instructions.
       
      -------------------------------------------------------------------------
       
      Updating from prior versions:
       
      Updating from Croppable Image 3 with versions prior to 1.1.7, please do this as a one time step:
      In the PW Admin, go to side -> modules -> new, use "install via ClassName" and use CroppableImage3 for the Module Class Name. This will update your existing CroppableImage3 module sub directory, even if it is called a new install. After that, the module will be recogniced by the PW updater module, what makes it a lot easier on further updates.
      -------------------------------------------------------------------------
       
      For updating from the legacy Thumbnail / CropImage to CroppableImage3 read on here.
       
      -------------------------------------------------------------------------
       
    • By MoritzLost
      UPDATE: I have published a stable version of this module!
      Discussion thread:
      Github: https://github.com/MoritzLost/TextformatterPageTitleLinks
      ---
      Hello there,
      I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution 🙂
      It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright 😅
      You can download the module from Github:
      https://github.com/MoritzLost/TextformatterPageTitleLinks
      There's some more information in the readme as well.
      Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.