Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#21 2020-07-09 19:29:01
- jakob
- Admin
- From: Germany
- Registered: 2005-01-20
- Posts: 4,036
- Website
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
#22 2020-07-10 05:58:19
- colak
- Admin
- From: Cyprus
- Registered: 2004-11-20
- Posts: 8,468
- Website
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.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.
Offline
#23 2020-07-10 11:44:32
- singaz
- Member
- From: Kyiv
- Registered: 2017-03-12
- Posts: 145
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
#24 2020-07-10 12:22:09
- colak
- Admin
- From: Cyprus
- Registered: 2004-11-20
- Posts: 8,468
- Website
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.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.
Offline
#25 2020-07-10 13:03:04
- colak
- Admin
- From: Cyprus
- Registered: 2004-11-20
- Posts: 8,468
- Website
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.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.
Offline
#26 2020-07-10 16:17:17
- colak
- Admin
- From: Cyprus
- Registered: 2004-11-20
- Posts: 8,468
- Website
Re: Media shortcode. Requests accepted
I’m not sure if they cover if the cookie names I have constructed cover most site_name
s 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.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.
Offline
#27 2020-07-10 16:37:59
- etc
- Developer
- Registered: 2010-11-11
- Posts: 4,079
- Website
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
#28 2020-07-10 17:23:00
- colak
- Admin
- From: Cyprus
- Registered: 2004-11-20
- Posts: 8,468
- Website
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.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.
Offline
#29 2020-07-10 18:45:39
- etc
- Developer
- Registered: 2010-11-11
- Posts: 4,079
- Website
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
#30 2020-07-11 05:08:24
- colak
- Admin
- From: Cyprus
- Registered: 2004-11-20
- Posts: 8,468
- Website
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.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.
Offline