Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2020-07-16 15:48:59

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Media shortcode. Requests accepted

I would love some suggestions re Giphy which offers two types of urls

  • giphy.com/gifs/name
  • giphy.com/videos/name

Their embed codes are independent of these but as this shortcode provides an external link to the page of the media based on their id, some of the resulting urls for giphy may be wrong. As such, I am thinking to:

  1. use the already existing url attribute and expect a value of videos or gifs
  2. use the same attribute and expect any value if it is a video or no value if it is a gif (implemented for now)
  3. Create a new attribute offering one of the options above.

What do you think would be the best method?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#38 2020-07-20 10:38:16

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Media shortcode. Requests accepted

This is ready and supports embeds from 15 external hosts, as well as 7 formats for the html5 audio element and 5 formats for the video element. It basically works for most hosts with the use of only 3 attributes.

I’ll have to add more attributes for my next version in order to deal with the complexities in the url schemas from hosts like Basecamp.

I hope that it’ll be of use to someone in the community.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#39 2020-07-20 12:43:24

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Media shortcode. Requests accepted

I added example for the new ones. I’ve found one issue

The one for Metacafe

Looking at the page source, it is showing the yield statement instead of the contents.

<div class="embed-container" id="m_12097962" itemscope itemtype="http://schema.org/VideoObject"> <iframe src="https://www.metacafe.com/embed/<txp:yield="media" />/" frameborder="0" allowfullscreen></iframe> </div>

Great Job. I had never heard of several of these sites.

Offline

#40 2020-07-20 13:28:17

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Media shortcode. Requests accepted

One other problem:

					<txp:if_yield name="m4a">
						<source src="<txp:site_url />files/<txp:variable name="audio_file" />.m4a" type="audio/m4a">
					</txp:if_yield>
					<txp:if_yield name="mp3">
						<source src="<txp:site_url /><txp:variable name="audio_file" />.mp3" type="audio/mpeg">
					</txp:if_yield>
					<txp:if_yield name="ogg">
						<source src="<txp:site_url /><txp:variable name="audio_file" />.ogg" type="audio/ogg">							
					</txp:if_yield>
					<txp:if_yield name="mp4">
						<source src="<txp:site_url /><txp:variable name="audio_file" />.mp4" type="audio/mp4">
					</txp:if_yield>
					<txp:if_yield name="aac">
						<source src="<txp:site_url /><txp:variable name="audio_file" />.aac" type="audio/aac">
					</txp:if_yield>
					<txp:if_yield name="webm">
						<source src="<txp:site_url /><txp:variable name="audio_file" />.webm" type="audio/webm">
					</txp:if_yield>
					<txp:if_yield name="flac">
						<source src="<txp:site_url /><txp:variable name="audio_file" />.ogg" type="audio/flac">
					</txp:if_yield>

Only the first one, m4a, includes /files/ in the url.

Offline

#41 2020-07-20 13:33:02

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Media shortcode. Requests accepted

michaelkpate wrote #324706:

Looking at the page source, it is showing the yield statement instead of the contents.

Perhaps <txp:yield="media" /> should be <txp:yield name="media" />?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#42 2020-07-20 13:43:24

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Media shortcode. Requests accepted

This isn’t an error but just an example of how to use it.

I don’t like embedding code in articles so I had been using custom fields.

        <txp:if_custom_field name="from">
            <txp::media from='<txp:custom_field name="from" />' media='<txp:custom_field name="media" />' title='<txp:custom_field name="title" />' url='<txp:custom_field name="url" />' escape="trim, tidy" />
        </txp:if_custom_field>

With the changes, I had to do some refactoring but this works.

        <txp:if_custom_field name="from">

                <txp:variable name="notlocal" value="yes" />

                <txp:if_custom_field name="from" value="local_v">
                                <txp::media from='<txp:custom_field name="from" />' media='<txp:custom_field name="media" />' title='<txp:custom_field name="title" />' <txp:custom_field name="url" />  escape="trim, tidy" />
                                <txp:variable name="notlocal" value="" />
                </txp:if_custom_field>

                <txp:if_custom_field name="from" value="local_a">
                                <txp::media from='<txp:custom_field name="from" />' media='<txp:custom_field name="media" />' title='<txp:custom_field name="title" />' <txp:custom_field name="url" /> escape="trim, tidy" />
                                <txp:variable name="notlocal" value="" />
                </txp:if_custom_field>

                <txp:if_variable name="notlocal" value="yes">
                                <txp::media from='<txp:custom_field name="from" />' media='<txp:custom_field name="media" />' title='<txp:custom_field name="title" />' url='<txp:custom_field name="url" />' escape="trim, tidy" />
                </txp:if_variable>

        </txp:if_custom_field>

Offline

#43 2020-07-20 13:45:43

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Media shortcode. Requests accepted

Bloke wrote #324708:

Perhaps <txp:yield="media" /> should be <txp:yield name="media" />?

That was indeed the problem. It is working now.

Offline

#44 2020-07-20 13:57:04

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Media shortcode. Requests accepted

michaelkpate wrote #324706:

I added example for the new ones. I’ve found one issue

The one for Metacafe

Looking at the page source, it is showing the yield statement instead of the contents.

<div class="embed-container" id="m_12097962" itemscope itemtype="http://schema.org/VideoObject"> <iframe src="https://www.metacafe.com/embed/<txp:yield="media" />/" frameborder="0" allowfullscreen></iframe> </div>...

Great Job. I had never heard of several of these sites.

That is strange. Did you fix it yourself? If not, it worked just fine from here (img below). Thanks for the files they were missing from both the local audio and video!


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#45 2020-07-20 14:00:03

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Media shortcode. Requests accepted

michaelkpate wrote #324710:

That was indeed the problem. It is working now.

Indeed or I think that I could just have <txp:yield media />. It may have worked for me on your site because of your correction!

Last edited by colak (2020-07-20 14:20:31)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#46 2020-07-20 14:14:11

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Media shortcode. Requests accepted

        <txp:if_custom_field name="from">
            <txp::media from='<txp:custom_field name="from" />' media='<txp:custom_field name="media" />' title='<txp:custom_field name="title" />' url='<txp:custom_field name="url" />' escape="trim, tidy" />
        </txp:if_custom_field>

This is fine, except the url may yield some unexpected results because of example 5, example 6, and example 8.

> Edited to add that my nomenclature for the url attribute may be misleading, as although it does return urls, the way it is used is different for each example.

Last edited by colak (2020-07-20 14:18:53)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#47 2020-07-20 14:32:05

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Media shortcode. Requests accepted

colak wrote #324712:

It may have worked for me on your site because of your correction!

It did. Sorry for the confusion.

Offline

#48 2020-07-20 14:34:15

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Media shortcode. Requests accepted

colak wrote #324715:

This is fine, except the url may yield some unexpected results because of example 5, example 6, and example 8.

I didn’t work through all the examples. I’ll have to rethink my approach – probably do a custom call for each site.

Offline

Board footer

Powered by FluxBB