WordPress.org

Ready to get started?Download WordPress

Forums

How To Pop Up Video Over An Image? (2 posts)

  1. hotinthenews
    Member
    Posted 9 months ago #

    Hi;
    I would like to have a video popup when users click on a image. I got part of it but am stuck with the popup knowing that "onclick" and "onmouseover" don't work with PHP, unless I resort to using AJAX, which I am not familiar with.

    Here's what I got:
    I write an article and embed entire video code <iframe ......></iframe> into a custom field I call 'Video'. I publish the article.

    At a separate page I created, I call the code stored in the custom field "Video" like so:

    $videos = get_post_meta( get_the_ID(), 'Video', true );

    $videos now contains the entire embed video code. Perfect.

    Then I display the featured image of the post :

    <img src="<?php echo $img; ?>" width="170" height="100" border="2">

    (I stored thumb_nail() into $img.)

    So far so good.

    When I load the page, the images all show up but I can't for the life of me get the corresponding video to open up on the same page when a viewer clicks or hoovers over the image.

    Any suggestions?

    Thanks

    Lode

  2. bcworkz
    Member
    Posted 9 months ago #

    You cannot do browser effects with PHP, it needs to be JavaScript or jQuery. You don't need AJAX though it could be used in some situations. You use PHP to ensure all information is on the page. It does not need to be visible, but it needs to be there if you are to avoid AJAX. The page is sent off to the browser, everything else is up to JavaScript/jQuery.

    You can create a div that appears to float over other content with JavaScript and CSS, but such effects are easier if you use jQuery and related libraries.

Reply

You must log in to post.

About this Topic