Search code examples
phplaravellaravel-4laravel-3

How to show an image in video player


I want to show image in player but I can't, My player is:

        <video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="250" height="200"
                                    poster="{{ public_path().'/content/video/title.jpg' }}"
                                    data-setup="{}">
                                <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
         </video>

I have the image title.jpg in fmti\public\content\video. But I get the error :

404 Not Found - http://fmti.md:8000/home/vagrant/Workspace/fmti/public/content/video/title.jpg"

So the image exist in this folder, I can't understand where is my error. Please help me. Thx in advance


Solution

  • public_path() is for the system path to the public directory and is meant to be used when doing file operations inside your application. The client however can't use an absolute system path that includes the home directory etc.
    What you want to use instead is the asset() function:

    poster="{{ asset('content/video/title.jpg') }}"
    

    This will generate an URI that's actually accessible by the browser.