• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

INCLUDE HTML, CSS AND JAVASCRIPT

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › INCLUDE HTML, CSS AND JAVASCRIPT

This topic is: not resolved
  • This topic has 1 reply, 2 voices, and was last updated 2 years, 2 months ago by Matt M..
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • January 9, 2021 at 1:22 pm #502594
    Nachoca
    Participant

    Hi all,

    Can anyone help me to include some codes in my page? I have seen that Youtube videos size is aroung 500Kb each. Reviewing on the internet, I have found a solution to reduce this size but I would have to include code in HTLM, CSS and Javascript.

    I am using Metro Pro Theme.

    If there is an easy way to reduce size, I will appreciate some feedback.

    The code that I have to include is the following in each page with video but maybe there is a way to include part of it as General.

    Below you can see the code that I'm talking about in case it helps.

    Best Regards,

    HTML

    <div class="contenedor">
    <div class="reproductor" data-id="here I will include each video code"></div>
    </div>

    CSS

    <style>
    .contenedor{
    display: block;
    margin: 20px auto;
    width: 100%;
    max-width: 600px;
    }
    .reproductor {
    display: block;
    width: 100%;
    height: 100%;
    padding-bottom: 56.25%;
    overflow: hidden;
    position: relative;
    cursor: hand;
    cursor: pointer;
    }
    img.imagen-previa {
    display: block;
    left: 0;
    bottom: 0;
    margin: auto;
    max-width: 100%;
    width: 100%;
    position: absolute;
    right: 0;
    top: 0;
    height: auto
    }
    div.youtube-play {
    height: 64px;
    width: 64px;
    left: 50%;
    top: 50%;
    margin-left: -36px;
    margin-top: -36px;
    opacity:0.7;
    position: absolute;
    background: url("https://cdn2.iconfinder.com/data/icons/social-icons-color/512/youtube-64.png") no-repeat;
    }
    div.youtube-play:hover{
    opacity:1;
    }
    #youtube-iframe {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    }
    </style>

    JAVASCRIPT

    <script>
    (function() {
    var v = document.getElementsByClassName("reproductor");
    for (var n = 0; n < v.length; n++) {
    var p = document.createElement("div");
    p.innerHTML = labnolThumb(v[n].dataset.id);
    p.onclick = labnolIframe;
    v[n].appendChild(p);
    }
    })();
    function labnolThumb(id) {
    return '<div class="youtube-play"></div>';
    }
    function labnolIframe() {
    var iframe = document.createElement("iframe");
    iframe.setAttribute("src", "//www.youtube.com/embed/" + this.parentNode.dataset.id + "?autoplay=1&autohide=2&border=0&wmode=opaque&enablejsapi=1&controls=0&showinfo=0");
    iframe.setAttribute("frameborder", "0");
    iframe.setAttribute("id", "youtube-iframe");
    this.parentNode.replaceChild(iframe, this);
    }
    </script>

    https://sonidodecuerdas.com/
    January 21, 2021 at 11:18 am #502775
    Matt M.
    Participant

    The easiest way to include in a specific page is by using the Gutenberg 'custom html' block. Then literally just copy and paste that code you shared into the block. I'd put it at the top of your page.

    I use this trick all the time to include custom CSS for an element that's only on one page, to avoid weighing down my main stylesheet.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble