Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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:
- use the already existing
url
attribute and expect a value ofvideos
orgifs
- use the same attribute and expect any value if it is a video or no value if it is a gif (implemented for now)
- 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
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
Re: Media shortcode. Requests accepted
I added example for the new ones. I’ve found one issue
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
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
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
Offline
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
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
Re: Media shortcode. Requests accepted
michaelkpate wrote #324706:
I added example for the new ones. I’ve found one issue
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
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 It may have worked for me on your site because of your correction!<txp:yield media />
.
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
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
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
Offline