Author
Message

How to Convert Youtube Links to Video Automatically for Seditio CMS?
This document I will explain is only valid for Seditio Forum System and Pages.

First, we open system/core/forums/forums.posts.inc.php and find the following.

$row['fp_text'] = sed_parse($row['fp_text']);

We add it below.

// YouTube linkini iframe'e çevir ve responsive hale getir
$row['fp_text'] = preg_replace(
    '/https:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/i',
    '<div class="embed-responsive embed-responsive-16by9"><iframe class="vid" src="https://www.youtube.com/embed/$2" allowfullscreen></iframe></div>',
    $row['fp_text']
);
// Eğer kısa URL formatında bir YouTube linki varsa (https://youtu.be/VIDEO_ID)
$row['fp_text'] = preg_replace(
    '/https:\/\/youtu\.be\/([a-zA-Z0-9_-]+)/i',
    '<div class="embed-responsive embed-responsive-16by9"><iframe class="vid" src="https://www.youtube.com/embed/$1" allowfullscreen></iframe></div>',
    $row['fp_text']
);

Youtube Video Auto Size for Pages
Open system/core/page/page.inc.php and find the following.

$pag['page_text'] = sed_parse($pag['page_text']);

We add it below.

// YouTube linkini iframe'e çevir ve responsive hale getir
$pag['page_text'] = preg_replace(
    '/https:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/i',
    '<div class="embed-responsive embed-responsive-16by9"><iframe class="vid" src="https://www.youtube.com/embed/$2" allowfullscreen></iframe></div>',
    $pag['page_text']
);
// Eğer kısa URL formatında bir YouTube linki varsa (https://youtu.be/VIDEO_ID)
$pag['page_text'] = preg_replace(
    '/https:\/\/youtu\.be\/([a-zA-Z0-9_-]+)/i',
    '<div class="embed-responsive embed-responsive-16by9"><iframe class="vid" src="https://www.youtube.com/embed/$1" allowfullscreen></iframe></div>',
    $pag['page_text']
);

Then we used the class=«vid» vid class in the relevant code to automatically size the video.

You need to add the following codes to your CSS file.

.vid {
  width: 100%;
  height: auto;
}
/* Büyük ekranlar için (992px ve üstü) */
@media (min-width: 992px) {
    .vid {
        width: 640px;
        height: 360px;
    }
}
/* Orta ekranlar için (768px - 991px arası) */
@media (min-width: 768px) and (max-width: 991px) {
    .vid {
        width: 640px;
        height: 360px; /* 480px değilse bunu açıklama kısmında belirtmeyin */
    }
}
/* Küçük ekranlar için (720px altı) */
@media (max-width: 767px) {
    .vid {
        width: 100%;
        height: auto;
    }
}

Now when you paste the YouTube link to your forum or blog page, the automatic video player will open.

https://www.youtube.com/watch?v=GuFTuKoXepw is enough to paste like this.

The process is complete.

You need to clear your cookies for the CSS to be active.

This process is valid for Seditio HTML versions.