Is there a way to make a BBCode token optional?

Get help developing custom BBCodes or request one.
User avatar
EA117
Registered User
Posts: 1858
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Is there a way to make a BBCode token optional?

Post by EA117 »

Bruce Banner wrote:
Fri Nov 20, 2020 9:54 am
Could it be something wrong with my code, or something wrong with the subtitle file? Maybe how I've formatted it, or what I've called it, or where I've stored it?
No worries, I think we're both on the same page. I was ultimately responding to the questions posed in this quote. Essentially agreeing with you, but stipulating that all of those answers ultimately lie outside out phpBB. It could very well have "something to do with the code above", or more specifically something that you will ultimately change in that BBCode definition in order to solve. But it will be after learning what HTML is needed to make the player do what you want it to do, and then updating your BBCode to actually construct this necessary HTML.
Bruce Banner
Registered User
Posts: 834
Joined: Thu Sep 25, 2014 10:36 am

Re: Is there a way to make a BBCode token optional?

Post by Bruce Banner »

EA117 wrote:
Fri Nov 20, 2020 12:39 pm
Bruce Banner wrote:
Fri Nov 20, 2020 9:54 am
No worries, I think we're both on the same page. I was ultimately responding to the questions posed in this quote. Essentially agreeing with you, but stipulating that all of those answers ultimately lie outside out phpBB. It could very well have "something to do with the code above", or more specifically something that you will ultimately change in that BBCode definition in order to solve. But it will be after learning what HTML is needed to make the player do what you want it to do, and then updating your BBCode to actually construct this necessary HTML.
I have managed to pin the problem down to one vital keyword, crossorigin.

BBCode usage

Code: Select all

[MP42 poster={URL2?} subtitle={URL3?}]{URL1}[/MP42]
HTML replacement

Code: Select all

<xsl:choose>
	<xsl:when test="@poster">
		<xsl:choose>
			<xsl:when test="@subtitle">
				<center><video controls="" crossorigin="" poster="{URL2}"><source src="{URL1}" type="video/mp4"></source><track kind="captions" label="English" srclang="en" src="{URL3}"></track></video></center>
			</xsl:when>
			<xsl:otherwise>
				<center><video controls="" crossorigin="" poster="{URL2}"><source src="{URL1}" type="video/mp4"></source></video></center>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:when>
	<xsl:otherwise>
		<center><video controls="" crossorigin=""><source src="{URL1}" type="video/mp4"></source></video></center>
	</xsl:otherwise>
	<xsl:when test="@subtitle">
		<xsl:choose>
			<xsl:when test="@poster">
				<center><video controls="" crossorigin="" poster="{URL2}"><source src="{URL1}" type="video/mp4"></source><track kind="captions" label="English" srclang="en" src="{URL3}"></track></video></center>
			</xsl:when>
			<xsl:otherwise>
				<center><video controls="" crossorigin=""><source src="{URL1}" type="video/mp4"></source><track kind="captions" label="English" srclang="en" src="{URL3}"></track></video></center>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:when>
	<xsl:otherwise>
		<center><video controls="" crossorigin=""><source src="{URL1}" type="video/mp4"></source></video></center>
	</xsl:otherwise>
</xsl:choose>
Works perfectly. With that code, if ya enter an MP4 URL on its own, just the video's first frame and the controls will display. If ya enter the video link and a poster link, the poster will display along with them. Video and a subtitle, just the first frame, the controls, and a subtitle will display. And if ya enter a video along with a subtitle and a poster, all three display perfectly.
Bruce Banner
Registered User
Posts: 834
Joined: Thu Sep 25, 2014 10:36 am

Re: Is there a way to make a BBCode token optional?

Post by Bruce Banner »

EA117 wrote:
Fri Nov 20, 2020 12:39 pm
No worries, I think we're both on the same page. I was ultimately responding to the questions posed in this quote. Essentially agreeing with you, but stipulating that all of those answers ultimately lie outside out phpBB. It could very well have "something to do with the code above", or more specifically something that you will ultimately change in that BBCode definition in order to solve. But it will be after learning what HTML is needed to make the player do what you want it to do, and then updating your BBCode to actually construct this necessary HTML.
I have managed to pin the problem down to one vital keyword, crossorigin.

BBCode usage

Code: Select all

[MP42 poster={URL2?} subtitle={URL3?}]{URL1}[/MP42]
HTML replacement

Code: Select all

<xsl:choose>
	<xsl:when test="@poster">
		<xsl:choose>
			<xsl:when test="@subtitle">
				<center><video controls="" crossorigin="" poster="{URL2}"><source src="{URL1}" type="video/mp4"></source><track kind="captions" label="English" srclang="en" src="{URL3}"></track></video></center>
			</xsl:when>
			<xsl:otherwise>
				<center><video controls="" crossorigin="" poster="{URL2}"><source src="{URL1}" type="video/mp4"></source></video></center>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:when>
	<xsl:otherwise>
		<center><video controls="" crossorigin=""><source src="{URL1}" type="video/mp4"></source></video></center>
	</xsl:otherwise>
	<xsl:when test="@subtitle">
		<xsl:choose>
			<xsl:when test="@poster">
				<center><video controls="" crossorigin="" poster="{URL2}"><source src="{URL1}" type="video/mp4"></source><track kind="captions" label="English" srclang="en" src="{URL3}"></track></video></center>
			</xsl:when>
			<xsl:otherwise>
				<center><video controls="" crossorigin=""><source src="{URL1}" type="video/mp4"></source><track kind="captions" label="English" srclang="en" src="{URL3}"></track></video></center>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:when>
	<xsl:otherwise>
		<center><video controls="" crossorigin=""><source src="{URL1}" type="video/mp4"></source></video></center>
	</xsl:otherwise>
</xsl:choose>
Works perfectly. With that code, if ya enter an MP4 URL on its own, just the video's first frame and the controls will display. If ya enter the video link and a poster link, the poster will display along with them. Video and a subtitle, just the first frame, the controls, and a subtitle will display. And if ya enter a video along with a subtitle and a poster, all three display perfectly.
Bruce Banner
Registered User
Posts: 834
Joined: Thu Sep 25, 2014 10:36 am

Re: Is there a way to make a BBCode token optional?

Post by Bruce Banner »

The second last post shouldn't have been approved. I posted it by mistake. Anyway, I've changed the code again. Added playsinline="" and default="". playsinline stops videos from automatically expanding to full screen on mobile devices and default makes subtitles display by default rather than having to be selected. The full code now reads,

BBCode usage

Code: Select all

[MP4 poster={URL2?} subtitle={URL3?}]{URL1}[/MP4]
HTML replacement

Code: Select all

<xsl:choose>
	<xsl:when test="@poster">
		<xsl:choose>
			<xsl:when test="@subtitle">
				<center><video controls="" crossorigin="" playsinline="" poster="{URL2}"><source src="{URL1}" type="video/mp4"></source><track kind="captions" label="English" srclang="en" src="{URL3}" default=""></track></video></center>
			</xsl:when>
			<xsl:otherwise>
				<center><video controls="" crossorigin="" playsinline="" poster="{URL2}"><source src="{URL1}" type="video/mp4"></source></video></center>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:when>
	<xsl:otherwise>
		<center><video controls="" crossorigin="" playsinline=""><source src="{URL1}" type="video/mp4"></source></video></center>
	</xsl:otherwise>
	<xsl:when test="@subtitle">
		<xsl:choose>
			<xsl:when test="@poster">
				<center><video controls="" crossorigin="" playsinline="" poster="{URL2}"><source src="{URL1}" type="video/mp4"></source><track kind="captions" label="English" srclang="en" src="{URL3}" default=""></track></video></center>
			</xsl:when>
			<xsl:otherwise>
				<center><video controls="" crossorigin="" playsinline=""><source src="{URL1}" type="video/mp4"></source><track kind="captions" label="English" srclang="en" src="{URL3}" default=""></track></video></center>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:when>
	<xsl:otherwise>
		<center><video controls="" crossorigin="" playsinline=""><source src="{URL1}" type="video/mp4"></source></video></center>
	</xsl:otherwise>
</xsl:choose>
User avatar
JoshyPHP
Code Contributor
Posts: 1177
Joined: Mon Jul 11, 2011 12:28 am

Re: Is there a way to make a BBCode token optional?

Post by JoshyPHP »

I haven't tested it but based on what I've seen, that template is equivalent to this:

Code: Select all

<center>
	<video controls="" crossorigin="" playsinline="">
		<xsl:copy-of select="@poster" />
		<source src="{@content}" type="video/mp4" />
		<xsl:if test="@subtitle">
			<track kind="captions" label="English" srclang="en" src="{@subtitle}" default="" />
		</xsl:if>
	</video>
</center>
I wrote the thing that does BBCodes in 3.2+.
Bruce Banner
Registered User
Posts: 834
Joined: Thu Sep 25, 2014 10:36 am

Re: Is there a way to make a BBCode token optional?

Post by Bruce Banner »

JoshyPHP wrote:
Sat Nov 21, 2020 4:32 pm
I haven't tested it but based on what I've seen, that template is equivalent to this:

Code: Select all

<center>
	<video controls="" crossorigin="" playsinline="">
		<xsl:copy-of select="@poster" />
		<source src="{@content}" type="video/mp4" />
		<xsl:if test="@subtitle">
			<track kind="captions" label="English" srclang="en" src="{@subtitle}" default="" />
		</xsl:if>
	</video>
</center>
Thanks. I'll test that and see if it works just as well. Just posted in the Img resize thread. Asked if you could explain how to use your imgsize extension.
Bruce Banner
Registered User
Posts: 834
Joined: Thu Sep 25, 2014 10:36 am

Re: Is there a way to make a BBCode token optional?

Post by Bruce Banner »

JoshyPHP wrote:
Sat Nov 21, 2020 4:32 pm
I haven't tested it but based on what I've seen, that template is equivalent to this:

Code: Select all

<center>
	<video controls="" crossorigin="" playsinline="">
		<xsl:copy-of select="@poster" />
		<source src="{@content}" type="video/mp4" />
		<xsl:if test="@subtitle">
			<track kind="captions" label="English" srclang="en" src="{@subtitle}" default="" />
		</xsl:if>
	</video>
</center>
Yep, that worked great. Thanks. :)
Post Reply

Return to “Custom BBCode Development and Requests”