Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Media shortcode. Requests accepted
Bloke wrote #324395:
Sorry, I meant just for SoundCloud, since they are the only ones that use the
url
andmedia
attributes. You could carry on usingmedia
for YouTube and others, but on SoundCloud you could add some extra detection there to see if the value passed into themedia
was all numeric or not.
So do you mean something like this?
<txp:if_yield name="from" value="sc">
<txp:if_yield name="media">
<txp:oui_cookie name='<txp:site_name trim="/\s+/" replace="_" />_soundcloud_cookie' duration="+1 year" values="yes" />
<txp:oui_if_cookie name='<txp:site_name trim="/\s+/" replace="_" />_soundcloud_cookie'>
<div class="embed-container" id="<txp:yield name="media" />"><iframe width="100%" height="300" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/<txp:yield name="media" />&color=%23ff5500&auto_play=false&hide_related=true&show_comments=false&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe></div>
<txp:else />
<div class="gdpr">
<txp:if_yield name="title"><txp:yield name="title" textile /></txp:if_yield>
<txp:if_yield name="media">
<txp:variable name="detectinteger" escape="tidy, integer"><txp:yield name="media" /></txp:variable>
<txp:if_variable name="detectinteger" value="">
<p>Hosted by <a rel="external noopener" href="https://soundcloud.com/">SoundCloud</a>.</p>
<txp:else />
<p>Hosted by SoundCloud on <a rel="external noopener" href="<txp:yield name="media" />"><txp:yield name="media" /></a>.</p>
</txp:if_variable>
</txp:if_yield>
<p><a rel="external noopener" href="https://soundcloud.com/pages/privacy">SoundCloud’s private policy</a>.</p>
<p class="accept"><a rel="nofollow noindex" href="?<txp:site_name trim="/\s+/" replace="_" />_soundcloud_cookie=yes#m_<txp:yield name="media" />">Listen to it here</a></p>
</div>
</txp:oui_if_cookie>
</txp:if_yield>
</txp:if_yield>
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 #324396:
Hi Michael, thanks for testing! That is strange! I’m not getting this error!
I wonder if it is a problem between oui_cookie and PHP 7.4?
http://demo.cmsstyles.com/datebasedarchives/2020/07/06/date-based-archives
http://demo.cmsstyles.com/typerite/2020/03/28/pvpets-tank-battle-royale-cinematic-trailer
The second site I already had some embeds going on but I decided to try and implemented your version for simplicity.
Offline
Re: Media shortcode. Requests accepted
Nope, this needs more thinking. If I use the media
attribute for both the embed and the GDPR warning, in SoundCloud, the embed code will be wrong as it needs a number.
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 #324398:
I wonder if it is a problem between oui_cookie and PHP 7.4?
I do not think so as I am using PHP version: 7.4.7. I am trying to see where I f*cked up.
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 also discovered another bug. I expected <txp:yield name="title" textile />
to be parsed by textile but after trying <txp::media from="v" media="336049258" title="h3. My awesome video" />
it returned h3. My awesome 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
colak wrote #324399:
Nope… If I use the
media
attribute for both the embed and the GDPR warning, in SoundCloud, the embed code will be wrong as it needs a number.
Ah, didn’t spot that it needed different things. That’s annoying. Okay, ignore me, sorry for the confusion.
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
colak wrote #324401:
I expected
<txp:yield name="title" textile />
to be parsed by textile
Sadly not. There’s no textile
attribute. escape="textile"
will though!
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
I tried installing it at https://prev-demo.textpattern.co/articles/welcome-to-your-site
Same error and this is running PHP version: 7.3.20.
> Textpattern Warning: Tag opening/closing mismatch: <txp:if_yield name="media">…</txp:oui_if_cookie>. while parsing form media on page archive
Tag error: <txp::media from="v" media="336049258" title="My awesome video" /> -> Textpattern Warning: Closing tag without corresponding opening tag: </txp:if_yield>. while parsing form media on page archive
Offline
Re: Media shortcode. Requests accepted
Cool idea Yiannis, but sadly no time to try it right now.
michaelkpate wrote #324404:
I tried installing it at https://prev-demo.textpattern.co/articles/welcome-to-your-site
Same error and this is running PHP version: 7.3.20.
It looks like txp:oui_if_cookie
is accidentally self-closed at the end of this line. Maybe that solves it.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Media shortcode. Requests accepted
Julian thanks! That was it! It’s strange that my sandspace running 4.9.0-dev (035482373c70b1b060b85ca77fe1f0c3) did not break.
Michael, thanks for testing and insisting on this!
Stef. No worries about the confusion and many thanks for the input!!!!
The shortcode currently supports
- Video
- Local mp4 video
- Internet Archive video
- YouTube
- Vimeo
- DailyMotion
- Giphy
- Audio
- Local mp3 audio
- Internet Archive audio
- AudioBoom
- IndieSound
- SoundCloud
- Other
- Google Maps (actually for the maps created in ‘My Maps’ https://www.google.com/mymaps)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#23 2020-07-10 11:44:32
- singaz
- Member
- Registered: 2017-03-12
- Posts: 150
Re: Media shortcode. Requests accepted
Actual topic! Thank you.
Now I need to fix the lazy load.
Recently made a lazy youtube load code:
<txp:hide> YouTube video SHORT-TAG
Use this in an article as:
<txp::youtube youtube-id="" />
<txp::youtube width="" height="" youtube-id="" alt-title="" description="" duration-seconds="" />
Attributes are:
width=""
height=""
youtube-id=""
alt-title=""
description=""
duration-seconds=""
</txp:hide>
<div itemscope itemtype="http://schema.org/VideoObject">
<txp:if_yield name="alt-title">
<meta itemprop="name" content="<txp:yield name="alt-title" />">
<txp:else />
<meta itemprop="name" content="<txp:title />">
</txp:if_yield>
<txp:if_yield name="description">
<meta itemprop="description" content="<txp:yield name="description" />">
<txp:else />
<meta itemprop="description" content="<txp:meta_description format="" />" />
</txp:if_yield>
<meta itemprop="thumbnailURL" content="https://img.youtube.com/vi/<txp:yield name="youtube-id" />/hqdefault.jpg" />
<meta itemprop="embedURL" content="https://www.youtube.com/embed/<txp:yield name="youtube-id" />" />
<meta itemprop="uploadDate" content="<txp:posted format="iso8601" />">
<txp:if_yield name="duration-seconds"><meta itemprop="duration" content="T<txp:yield name="duration-seconds" />S"></txp:if_yield>
<iframe
width="
<txp:if_yield name="width">
<txp:yield name="width" />
<txp:else />
640
</txp:if_yield>"
height="
<txp:if_yield name="height">
<txp:yield name="height" />
<txp:else />
480
</txp:if_yield>"
src="https://www.youtube.com/embed/<txp:yield name="youtube-id" />"
srcdoc="
<style>
*{padding:0;margin:0;overflow:hidden}
html,body{height:100%}
img,span{position:absolute;width:100%;top:0;bottom:0;margin:auto}
span{height:1.5em;text-align:center;font:48px/1.5 sans-serif;color:white;text-shadow:0 0 0.5em black}
</style>
<a href=https://www.youtube.com/embed/<txp:yield name="youtube-id" />?autoplay=1>
<img src=https://img.youtube.com/vi/<txp:yield name="youtube-id" />/hqdefault.jpg
<txp:if_yield name="alt-title"> alt='<txp:yield name="alt-title"/>' </txp:if_yield> >
<span>▶</span>
</a>"
frameborder="0"
allow="accelerometer;
autoplay;
encrypted-media;
gyroscope;
picture-in-picture"
allowfullscreen
<txp:if_yield name="alt-title">title="<txp:yield name="alt-title" />"</txp:if_yield>>
</iframe>
</div>
Last edited by singaz (2020-07-10 12:13:54)
Sorry my horror English. I’m learning textpattern, I’m learning English
Offline
Re: Media shortcode. Requests accepted
singaz wrote #324409:
Actual topic! Thank you.
Now I need to fix the lazy load.
Recently made a lazy youtube load code:
<txp:hide> YouTube video SHORT-TAG...
Yours is actually more thorough, alas not GDPR compliant. I tried to keep this as simple as possible.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline