Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
mediaattribute 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.
Hire 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.
Hire 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
Re: Media shortcode. Requests accepted
I like youtube’s correlation between the url and the video image. As such the particular code can be amended to:
<txp:hide>YouTube</txp:hide>
<txp:if_yield name="from" value="yt">
<txp:if_yield name="media">
<txp:oui_cookie name='<txp:site_name trim="/\s+/" replace="_" />_youtube_cookie' duration="+1 year" values="yes" />
<txp:oui_if_cookie name='<txp:site_name trim="/\s+/" replace="_" />_youtube_cookie'>
<div class="embed-container" id="m_<txp:yield name="media" />"><iframe src="https://www.youtube.com/embed/<txp:yield name="media" />?rel=0" frameborder="0" allowfullscreen></iframe></div>
<txp:else />
<div class="gdpr">
<img src="https://i3.ytimg.com/vi/<txp:yield name="media" />/hqdefault.jpg" <txp:if_yield name="title">alt="<txp:yield name="title" />"</txp:if_yield> />
<txp:if_yield name="title"><txp:yield name="title" escape="textile" /></txp:if_yield>
<p>Hosted by YouTube on <a rel="external noopener" href="https://youtube.com/<txp:yield name="media" />">youtube.com/<txp:yield name="media" /></a>.</p>
<p><a rel="external noopener" href="https://youtube.com/privacy">YouTube’s private policy</a>.</p>
<p class="accept"><a rel="nofollow noindex" href="?<txp:site_name trim="/\s+/" replace="_" />_youtube_cookie=yes#m_<txp:yield name="media" />">View 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
I’m not sure if they cover if the cookie names I have constructed cover most site_names as I am thinking that site names with an ampersand or other special characters, including non Latin ones may not produce a valid result.
Sample code
<txp:oui_cookie name='<txp:site_name trim="/\s+/" replace="_" />_soundcloud_cookie' duration="+1 year" values="yes" />
Could someone provide some advice here?
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
To replace everything non-alphanumeric:
<txp:site_name trim="/\W+/" replace="_" />
or
<txp:site_name trim="/[^a-zA-Z]+/" replace="_" />
to keep only Latin characters.
Offline
Re: Media shortcode. Requests accepted
Hi Oleg, Thanks but it does not solve the problem. I changed the site name to 文字模式 岩石 and I understandably only get one underscore. I’m now thinking that trimming the site url from its http(s)://, www, extension, subdomain, and/or sub-directory might be a safer idea or even just set a user defined variable for the cookie prefix which is simpler. nope:) It’s not simpler:)
Last edited by colak (2020-07-10 17:50:24)
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
You can register md5 function for use in <txp:evaluate /> and call your cookies
<txp:evaluate query='md5("<txp:site_name />")' />_whatever_cookie
Offline
Re: Media shortcode. Requests accepted
It’s a good idea Oleg, but is is too abstract. I am trying to make that prefix more descriptive so, for the first time, plunging myself into the joys of regex with the help of regex101.com/ and www.phpliveregex.com/. I expected the following to work for any domain.tld or domain.xx.yy and it behaves well in the regex site although I am yet to figure out how to include an optional s after the http, as well as an optional anything for the subdomain. (dev is a subdomain I am working on).
Regardless, it does not behave in txp as it returns domain.tld instead of just the expected domain. Does anyone have any idea of how it could be adapted for our cms?
<txp:site_url trim="http:\/\/(?:dev\.)?([a-z0-9\-]+)(?:\.[a-z\.]+[\/]?).[^ ]/i" />
> and minutes after posting this, I remembered that there are domain names using non-Latin characters:)… But I do not remember any txp sites running under such domains.
Last edited by colak (2020-07-11 05:34:00)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline