I'm working on a wordpress plugin that streams videos using video js lib, but i can't figure out how my code automatically generates this (” and ″) in all my url supplied to the player.
this is what talking about, this is the url of the file :
"”https://s3-us-west-2.amazonaws.com/test-past3/data/Andrew+Cranston+-+Banners+of+Progress.mp4″"
this is my video player code:
<video class="video-js vjs-skin-flat-red vjs-16-9" id="<?php print $attr['video_id'];?>" style="max-width: 100%;"
controls
preload="<?php print $attr['preload']; ?>"
width="<?php print $width?>"
<?php print $muted ? "muted" : ""?>
height="<?php print $height?>"
poster="<?php print $attr['poster'];?>"
data-setup='{
"plugins": {
"vastClient": {
"adTagUrl": "<?php print $attr['adtagurl']; ?>",
"adCancelTimeout": 5000,
"adsEnabled": true
}
}
}'>
<source src="<?php print $attr['url']; ?>" type="<?php print $mime_type ?>"></source>
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser that
<a href="http://videojs.com/html5-video-support/" target="_blank">
supports HTML5 video
</a>
</p>
</video>
Just use the substr() function :
<source src="<?php print substr($attr['url'], 1, -1); ?>"
But i recommand you to find why your $attr['url'] come with quotes :)
Another two solutions with str_replace() and preg_replace().
str_replace(['”', '″'], '', $url);
preg_replace('/[”″]+/', '', $url);
But substr() is simpler and faster in this specific case (remove first and last characters from string).
substr($url, 1, -1);
Related
HI guys i am trying to get the image/video filename from path
Here i have paths in my php variable like this from database
E:/xampp/htdocs/pes/new/movie.mp4
E:/xampp/htdocs/pes/new/flowers.jpg
And i am trying to get new/movie.mp4 or new/flowers.jpg from above paths and display it in img tag or video tag
<img src="new/flowers.jpg" alt="Trulli" width="500" height="333">
or
<video width="400" controls>
<source src="new/movie.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
Can anyone help me how to do that
Thanks in advance
Hope this will help you :
Set your base_url in your config.php
$config['base_url']='http://localhost/pes/'
and ur image src should be like this :
<img src="<?=site_url('new/'.$image); ?>" alt="Trulli" width="500" height="333">
Try with base_url(). Set your base_url in config.php for example www.xyz.com/ Update your code like this:
<img src="<?php echo base_url() ?>new/flowers.jpg" alt="Trulli" width="500" height="333">
And video frame:
<video width="400" controls>
<source src="<?php echo base_url() ?>new/movie.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
Hope this will help you!
If all paths are relative to FCPATH, FCPATH = 'E:/xampp/htdocs/pes', you can use:
<img src="<?php echo base_url(str_replace(FCPATH, '', 'E:/xampp/htdocs/pes/new/flowers.jpg')) ?>" alt="Trulli" width="500" height="333">
or
<video width="400" controls>
<source src="<?php echo base_url(str_replace(FCPATH, '', 'E:/xampp/htdocs/pes/new/movie.mp4')) ?>" type="video/mp4">
Your browser does not support HTML5 video.
</video>
below code display the audio, audio tag works perfectly, it play the music in local server, but on live server audio not working, its not playing the music. it is appearing like disabled things in chrome and in mozilla it is not even showing the play button. i think problem is with source url.
<audio controls id = "myaudio">
<source src="<?php echo base_url(); ?>worship/assets/<?php echo $row->language_folder; ?>/<?php echo $row->album_folder; ?>/<?php echo $row->song_name; ?>" type="audio/mp3">
</audio>
Please advise me.
Hope this will help you :
Just change the Media Type OR MIME-type from audio/mp3 to audio/mpeg
<source type="audio/mpeg" src="<?php echo base_url(); ?>worship/assets/<?php echo $row->language_folder; ?>/<?php echo $row->album_folder; ?>/<?php echo $row->song_name; ?>" >
and use base_url like this (just suggestion) ;
<source type="audio/mpeg" src="<?php echo base_url('worship/assets/'.$row->language_folder.'/'.$row->album_folder.'/'.$row->song_name); ?>" >
For more :
https://www.w3schools.com/tags/tag_audio.asp
I am working on a WordPress website locally, where I am currently trying to dynamically call a Custom Header. I am using the following code:
<img src="<?php header_image(); ?>" height="20%<?php echo get_custom_header()->height; ?>" width="20%<?php echo get_custom_header()->width; ?>" alt="header-image" />
The above code, outputs the following line to the Browser:
<img src="http://localhost/wordpress-folder/wp-content/uploads/2017/10/image.jpg" height="20%3484" width="20%2439" alt="header-image" />
Though the above code successfully calls the Custom Header, it does fail W3C Validation. The error message is as follows:
Bad value 20%3484 for attribute height on element img: Expected a
digit but saw % instead.
The only way I can seem to remove this error, is by removing the % (px also produces the error) and only leave in the number.
Is there a way I could continue using Pixels/Percentage other than reorganising my code, so that I could implement some Inline/External Style Sheets?
You are using HTML height and width attributes. When you pass values to them you cannot pass the metric (e.g.: %, px etc) to it.
You will have to change your line to:
<img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="header-image" />
Hope this helps. :)
This should throw an error as it's not in a correct format. It should be either in % format or px format. 20%3484 is an incorrect format.
If you want to give fixed height, you can use this:
<img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="header-image" />
or if you want to use %, then use this:
<img src="<?php header_image(); ?>" height="20%" width="20%" alt="header-image" />
But you can only use one of them.
Let me know if it helps.
I have a string, an img url, in a php block called $str. And I want to set that string as the img src in an img src but its not working.
<img src="<?php $str ?>" height="50px" width="50px">
how else can i set the src to the $str string?
<img src="<?php echo $str;?>" height="50px" width="50px">
Well, I found correct answer for this problem. Nothing works well from above answers, that codes only print out source string to html page on site.
This works for me (I have my function that return source string of picture):
require_once("../../my_coded_php_functions.php");
<?php echo '<img src="' . getSourcePathOfImage() . '" />' ?>
This site(article) helped me to find and understand solution:
http://php.net/manual/en/faq.html.php
<?php echo '<img src="'.$str.'" height="50px" width="50px">' ?>
Other ways, although is not recommended. You may try :
<img src="<?=$str?>" height="50px" width="50px">
this will work, only if (in php.ini)
short_open_tag = On
<img src="…/<?php echo "$ArtFilePath"; ?>">
gives me this. It’s actually the one I want only without the …
http://markdinwiddie.com/PHP2012/.../artwork/Drawings/Boy.jpg
<img src="../<?php echo "$ArtFilePath"; ?>">
give me this
http://markdinwiddie.com/artwork/Drawings/Boy.jpg
<img src="/../<?php echo "$ArtFilePath"; ?>">
gives me this
http://markdinwiddie.com/artwork/Drawings/Boy.jpg
and
<img src="/…/<?php echo "$ArtFilePath"; ?>">
gives me this
http://markdinwiddie.com/.../artwork/Drawings/Boy.jpg
What I need is
http://markdinwiddie.com/PHP2012/artwork/Drawings/Boy.jpg
Who knows the order of dots and slashes?
Since $artFilePath == "artwork/Drawings/Boy.jpg", you want either:
Relative urls
Provided your php file is within /PHP2012/ this will work. It will even work if you rename the directory
<img src="<?php echo $ArtFilePath ?>" />
Which outputs
<img src="artwork/Drawings/Boy.jpg" />
Absolute urls
<img src="/PHP2012/<?php echo $ArtFilePath ?>" />
Which outputs
<img src="/PHP2012/artwork/Drawings/Boy.jpg" />
if the webpage is within the PHP2012 folder: http://markdinwiddie.com/PHP2012/
and your image is in artwork/Drawings/Boy.jpg within the PHP2012 folder
can't you just do <img src="<?php echo "$ArtFilePath"; ?>">