• I’m trying to display an HTML5 video in the header of the frontpage but the page doesn’t load and I get an error message Parse error: syntax error, unexpected ‘{‘, expecting ‘,’ or ‘;’ in

    This is the code that I’m using;

    <?php if (is_front_page())echo '<video id="example_video_1" class="video-js vjs-default-skin"
    controls preload="auto" width="1278" height="720"
    poster="https://imagestocksg.s3.amazonaws.com/preview/homepage-poster-test.jpg"
    data-setup='{"example_option":true}'>
    <source src="https://imagestocksg.s3.amazonaws.com/preview/homepage-video-test.mp4"
    type='video/mp4' />
    </video>'; ?>

    If I use an embedded Youtube video with an iframe it works fine;
    <?php if (is_front_page())echo '<iframe id="video-bg" src="//www.youtube.com/embed/vLUNWYt3q1w?rel=0&autoplay=1&controls=0&loop=1" frameborder="0" allowfullscreen></iframe>'; ?>

    I’m not a coder and really struggling to find a solution for this. I’ve looked everywhere. I’m assuming there’s an error with the coding but not sure what it is?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Adrian

    (@adrianfraguela)

    Hi,

    Yes you do have an error in your code.

    What are you using data-setup for?

    Try this:

    <?php
    	if (is_front_page()){
    		echo '
    		<video
    			id="example_video_1"
    			class="video-js vjs-default-skin"
    			controls
    			preload="auto"
    			width="1278"
    			height="720"
    			poster="https://imagestocksg.s3.amazonaws.com/preview/homepage-poster-test.jpg"
    			data-setup=''>
    				<source src="https://imagestocksg.s3.amazonaws.com/preview/homepage-video-test.mp4" type='video/mp4' />
    		</video>';
    	}    ?>
    Thread Starter metice

    (@metice)

    Hi Adrian,

    Thanks for taking a look at this. I’ve tried the code but still getting an error. This time it reads;
    Parse error: syntax error, unexpected ”> ‘ (T_CONSTANT_ENCAPSED_STRING), expecting ‘,’ or ‘;’ in….

    Not sure where I picked up the ‘data-setup’. To be honest, I don’t even know what it does!

    Adrian

    (@adrianfraguela)

    Try this one.

    <?php
    	if (is_front_page()){
    		echo '
    		<video
    			id="example_video_1"
    			class="video-js vjs-default-skin"
    			controls
    			preload="auto"
    			width="1278"
    			height="720"
    			poster="https://imagestocksg.s3.amazonaws.com/preview/homepage-poster-test.jpg"
    			>
    				<source src="https://imagestocksg.s3.amazonaws.com/preview/homepage-video-test.mp4" type="video/mp4" />
    		</video>';
    	}    ?>
    Thread Starter metice

    (@metice)

    Thanks Adrian, that’s perfect!

    Just in case it helps anyone else, where was I going wrong?

    Adrian

    (@adrianfraguela)

    No problem,

    It was your actual PHP code that was wrong. It was incorrectly nested.

    Thread Starter metice

    (@metice)

    Thanks for your help, Adrian

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Problem when using conditional tag 'is_front_page' and a tag’ is closed to new replies.