• Resolved amosajo

    (@amosajo)


    I am setting up a video blog for a client. When I place the URL of a youtube video in the body, for some reason the video does not embed on the actual post. The link is displayed as text. Thank you for your assistance

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Wayne Allen

    (@wayneallen-1)

    I suspect your email client is wrapping an anchor element around your link.

    You put: https://www.youtube.com/watch?v=y4fOKgBMpA8 in your email, but your email client transforms it into <a href="https://www.youtube.com/watch?v=y4fOKgBMpA8">https://www.youtube.com/watch?v=y4fOKgBMpA8</a>

    In this case WordPress doesn’t recognize this as an embedded link.

    You might be able to configure your mail client to not do this (unlikely).

    Another option is to send these emails as plain text rather than rich text, then the mail client won’t add the extra markup.

    Thread Starter amosajo

    (@amosajo)

    I’m using gmail. I tried using the plain text option, but the issue persists.

    Would support logs verify that the anchor tag is indeed the problem that I am experiencing?

    Also, if this is the case, do you recommend a client that will not add the anchor tag to my links?

    Thank You,

    Amos

    Thread Starter amosajo

    (@amosajo)

    Also,
    I’m curious as to whether or not the anchor tag is being added because the URLs are not hyperlinked in the posts that I generate

    Plugin Author Wayne Allen

    (@wayneallen-1)

    Can you send a sample email with a video link to [email protected] and I will try and figure out what is happening.

    Thread Starter amosajo

    (@amosajo)

    Hello Wayne,

    I have sent an email now. I think it might be helpful to note that I am using a plug-in called Elementor which is performing the styling of the display of my posts

    Thread Starter amosajo

    (@amosajo)

    Hello Wayne,

    Could you let me know whether or not you have observed the issue I reported?

    Thank you,

    Amos Ajo

    Thread Starter amosajo

    (@amosajo)

    okay, discovered I need two newlines after the video URL for video to embed nicely in the post…

    Plugin Author Wayne Allen

    (@wayneallen-1)

    I have been able to replicate what you are experiencing and adding the extra line worked for me as well. A little strange, something in the WordPress editor must have changed, because this all worked before. I’ll see if there is anything I can do.

    Plugin Author Wayne Allen

    (@wayneallen-1)

    It does seem to be isolated to the editor as the post displays the video correctly without making any changes to the imported email.

    Plugin Author Wayne Allen

    (@wayneallen-1)

    In fact making any change in the editor causes the editor to display the video.

    I have been having this problem for a while now, so decided to have a look at the PHP code and have something that works, but needs improving.
    In the “filter_CleanHtml” function of postie-filters.php, I have modified some of the code as shown below, so that it looks for “a” tags and then modifies the outertext accordingly and adds “embed” around the link. I could not get it to work any other way.

    I am using Outlook 365 as my email client.

    I had set “plain text” emails to get the links to embed properly, but any link that was over 75 or 80 characters would then end up getting broken in my post (a common problem for me). This (below) converts Youtube and MP3 links to embeds. Perhaps this can be added in the next update – and improved slightly to draw on WordPress’s current list of embeddable types of links/things (Dailymotion etc)

     foreach ($html->find('script, style, head,a') as $node) {
                    //DebugEcho("filter_CleanHtml: Removing: "  . $node->tagname . "=" .$node->nodename . "=" . $node->nodetype . "=" . $node->nodevalue . "=" . $node->innertext);
    				if(isset($node->href))
    				{
    				    if (strstr($node->innertext, "youtube.com") || (strstr($node->innertext, ".mp3")))
    					{
    						DebugEcho("filter_CleanHtml: Setting Link so that it will embed.");
    						$node->outertext="[embed]" . $node->innertext . "[/embed]";
    					}
    				}
    				else
    				{
    	 				DebugEcho("filter_CleanHtml: Removing: "  . $node->innertext);
    					$node->outertext = '';
    				}
    Plugin Author Wayne Allen

    (@wayneallen-1)

    Thanks for the sample code, this is on my list to do at some point.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘YouTube video is not embedding in my post’ is closed to new replies.