MYSQL add a param to disable suggested video param for the Youtube iframe
Ngo Nguyen Cong
? Remote Fullstack & Backend Developer | Web Development, Database Optimization| PHP, Node.js, MySQL, MongoDB
How To Disable Related Videos on a YouTube Embed
You can disable suggested and related videos by adding rel=0 to the HTML code. This is important for businesses and converting leads on your website.
Do this by clicking on the share button, embed, copying the code, and then pasting rel=0 after the video URL in the HTML code. When you embed that on your website it will only show videos from your channel when someone pauses the video or finishes it.
How to query add ?rel=0 in MYSQL for all src in Youtube iframe.
To modify a MySQL query to add ?rel=0 to all YouTube iframe src attributes, we'll need to use a string manipulation function. Here's a query that should accomplish this
UPDATE your_table_name
SET your_column_name = REGEXP_REPLACE(
your_column_name,
'src="(https?://www\\.youtube\\.com/embed/[^"]+)"',
'src="\\1?rel=0"'
)
WHERE your_column_name LIKE '%youtube.com/embed/%'
AND your_column_name NOT LIKE '%?rel=0%';
This query does the following:
You'll need to replace your_table_name and your_column_name with your actual table and column names.
A few things to note:
?AWS Cloud - Tymer
5 个月Smart! SQL for bulk URL editing streamlines YouTube embed customization.