I am trying to set the poster image of an HTML Video via PHP, but no luck so far.
<video class="friend-video" width="100%" poster="<?php the_sub_field('thumbnail_select'); ?>" muted loop>
Does anyone know how I could make this work?
I'm using Advanced Custom Fields.
Related
I'm trying to embed an self hosted video into a wordpress page. This is a video hosted in the media library on the same wordpress install.
But I'm having difficulties getting the video to appear on the page, not on autoplay and with sound.
It seems to either:
appear with no play button (looks like a static image)
appear autoplaying but with no sound.
I've tried various settings on the page code to get this to appear like a regular video with a play button that's not set to autoplay but I'm stumped.
These were the settings when I came to change them
<div class="video-area">
<video width="100%" autoplay muted>
<source src="<?php the_field('video_section_video') ?>" type="video/mp4">
</video>
</div>
I then tried this:
<div class="video-area">
<video width="100%" muted="false" autoplay="false">
<source src="<?php the_field('video_section_video') ?>" type="video/mp4">
</video>
</div>
And I also tried changing the original default settings to removing autoplay and muted, but no combination of changes seems to have the effect I want.
It's either static and no option to start the video, or it plays automatically without sound. I understand browsers dont allow videos to autoplay these days with sound, but I just need it to appear like a regular video with a play button.
You are missing controls
<div class="video-area">
<video width="100%" muted="false" autoplay="false" controls>
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video>
For your reference: https://www.w3schools.com/html/html5_video.asp
I'm using official WordPress AMP plugin to create my custom WordPress theme. For images I use
<?php if(has_post_thumbnail()):?>
<img class="img2" src="<?php the_post_thumbnail_url('blog-small'); ?>" alt="<?php the_title();?>">
<?php endif;?>
I get regular alt attribute as expected but the alt attribute is missing in some auto generated AMP codes. Here is an example of that code:
<img alt aria-hidden="true" class="i-amphtml-intrinsic-sizer" role="presentation" src="data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9JzIxMCcgd2lkdGg9JzQwMCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJyB2ZXJzaW9uPScxLjEnLz4=">
As you can see here the alt attribute do not contain any value. Can any one help me to solve the problem? I'm not looking for AMP validation. Missing alt can harm SEO. If you wish you can provide a code snippet so that I can understand it easily. (I'm a new coder)
This is my html
<div align="center" class="embed-responsive embed-responsive-16by9" width="640" height="480">
<video autoplay loop class="embed-responsive-item" controls>
<source src="/projects/moviestream/php/stream.php">
</video>
</div>
and my stream.php
// class definition of video_stream
$stream = new VideoStream($video_link);
$stream->start();
My question is how to pass the variable $video_link from my html to the php page so it streams the correct video?
Found a solution using just plain php!
I use a kind of php router that allows me to route movie/1 to VideoStreamer and invoking the method stream($id) wwith $id set to 1
I'm using Advanced Custom Fields plugin for custom fields in WordPress, and I tried to embed YouTube videos by adding one more custom fields where I write the YouTube video IDs. And I added the snippet below to the realted content php file, but it did not work. Could you please tell me what is wrong with the code? Thanks.
<div class="videoembed">
<?php $embedcode = the_field('video-embed');
echo do_shortcode("[embedyt]http://www.youtube.com/watch?v=" .$embedcode. "&width=600height=350[/embedyt]"); ?>
</div>
I had the problem myself and found a solution that worked!
the field type must not be oembed, but must be single-line text
and than it works with this code:
<?php // use inside loop echo $youtubevideo_code = wp_oembed_get( get_field('video_url') ); ?>
You don't need to use shortcode in your case, just write iframe tag :
<iframe src="<?php echo $embedcode; ?>" width="600" height="350" frameborder="0"></iframe>
I'm getting started using Kohana framework. How do I properly link images? I'm linking images using the usual way:
<img src="../../resources/images/img01.jpg" />
I'm using dreamweaver, and I can see that the link is correct. Since I can see an image in the preview:
The link is still the same when I reference the image based on the controller.
Best way to use full (base)paths:
<img src="<?php echo url::base() ?>resources/images/img01.jpg" />
or:
<img src="<?php echo url::site('resources/images/img01.jpg') ?>" />
You need to use absolute links. Either use html::image(), or prefix your image with url::base(), or use url::site(). There's lots of options, read the documentation.