팁과노하우

2024.11.06 15:49

게시글에 view.skin.php에서 유투브 링크 삽입하면 바로 영상 플레이되게 하는것

  <?php //echo get_view_thumbnail($view['content']); ?>

를 추석처리후에 아래처럼 바꿔주세요

스타일 넣어주시구요


<style>

.youtube_wrap {

    position: relative;

    padding-bottom: 56.25%; /* 16:9 aspect ratio */

    height: 0;

    overflow: hidden;

    max-width: 100%;

    background: #000;

    margin-top: 20px;

}

.youtube_wrap iframe {

    position: absolute;

    top: 0;

    left: 0;

    width: 100%;

    height: 100%;

}


</style>


<?php

    // Process the content using get_view_thumbnail

    $processed_content = get_view_thumbnail($view['content']);


    // Further process the output to embed YouTube URLs responsively

    $processed_content = preg_replace_callback(

        '/(?<!<a href=")https:\/\/(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11})(?!")/',

        function($matches) {

            $youtube_id = $matches[1];

            return '<div class="youtube_wrap">

                        <iframe src="https://www.youtube.com/embed/' . $youtube_id . '" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

                    </div>';

        },

        $processed_content

    );

    echo $processed_content;

?>

  • 공유링크 복사
    미니홈 쪽지 구독하기
    구독하고 알림받기

    댓글목록

    profile_image
    캐스퍼미니홈 1:1 대화하기  오래 전

    음 교체해도  플레이어가 안되네요?
    ---------------------------------------------------
                        echo get_file_thumbnail($view_file);
                    }

                    echo "</div>\n";
                }

            ?>
    <?php //echo get_view_thumbnail($view['content']); ?>
            <style>
    .youtube_wrap {
        position: relative;
        padding-bottom: 56.25%; /* 16:9 aspect ratio */
        height: 0;
        overflow: hidden;
        max-width: 100%;
        background: #000;
        margin-top: 20px;
    }

    .youtube_wrap iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
    </style>

    <?php
        // Process the content using get_view_thumbnail
        $processed_content = get_view_thumbnail($view['content']);
        // Further process the output to embed YouTube URLs responsively
        $processed_content = preg_replace_callback(
            '/(?<!<a href=")https:\/\/(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11})(?!")/',
            function($matches) {
                $youtube_id = $matches[1];
                return '<div class="youtube_wrap">
                            <iframe src="https://www.youtube.com/embed/' . $youtube_id . '" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
                        </div>';
            },
            $processed_content
        );
        echo $processed_content;
    ?>
        </div>
       
       
        <div id="bo_v_share">

    2024-11-06 16:54

    profile_image
    no_profile 삼다수미니홈 1:1 대화하기  오래 전

    본문에 주소 넣는 거에요.

    2024-11-07 12:48

    profile_image
    미키손미니홈 1:1 대화하기  오래 전

    잘 쓰겠습니다
    감사합니다
    mp4파일도 만들어주세요^^

    2024-11-07 08:45

    profile_image
    no_profile 삼다수미니홈 1:1 대화하기  오래 전

    https://youtu.be/rAl60pn468g?si=5EuxgoijX15ZIhuQ 넣으면
    동영상은 나오지만 동영상 옆으로 ?si=5EuxgoijX15ZIhuQ 남습니다.

    본문에 넣는 것도 좋지만 링크1, 2 에 넣는 방법도 공유해 주시면 감사하겠습니다. ^^

    2024-11-07 11:59