How to put image path in html::image() from database - image

I wanna put an image path in may laravel code like this
{!!Html::image({{$mdata->company_logo}},'logo',['width'=>60,'height'=>55])!!}
but {{$mdata->company_logo}} gives an error to html::image. I'm sure that image path from $mdata->company_logo has a valid data, namely the image path, because I can see it by using dd($data->company_logo).. But why html::image can't show the image...??
Thanks in advance.. :)

You shouldn't put the {{ }} around the $mdata->company_logo.
You are already inside a php block by using {!! !!} around Html::image().
Try {!!Html::image($mdata->company_logo,'logo',['width'=>60,'height'=>55])!!}.

Related

Escaping raw html in blade template files

i hope you're having a good day.
i have some raw html that i want to render inside my blade file,
ive tried the {!!...!!} syntax but for some reason it is not working for me, when i use this
{ !! $jobs[0]->content !!}
i get this result
My laravel version is >8.
Thank you for your answer.
The syntax is without the space. Removing your leading space will solve your issue.
{!! $jobs[0]->content !!}
https://laravel.com/docs/8.x/blade#displaying-unescaped-data

laravel display image from database with blade

i just stored the path of a image that i uploaded into the database, however in the edit section of the form i want to show it and dont seem to find how is the right way to display it i have been trying with:
{{ HTML::image('imgs/picture.jpg') }} -> this one shows the path correctly BUT
using -> {!! Html::image('product_image') !!} doesnt display the path correctly if i use the chrome developer tools inspector i get this:
<img src="http://127.0.0.1:8000/product_image">
what am i doing wrong? what i want is to display the info (the path of the image) that is stored on the database.
thanks!
use Storage::url() ref link https://laravel.com/docs/8.x/filesystem#file-urls
{{ HTML::image(Storage::url('imgs/picture.jpg')) }}
//or
{{ HTML::image(Storage::url($product_image)) }} // here $product_image database path stored by Storage::put() function
it will generate url for laravel storage path like
<img src="http://127.0.0.1:8000/storage/imgs/picture.jpg"> it is correct path

How to show image from database to blade in Laravel 5

I will put the image with tag in database. It can be svg also.
Like this:
Now I want to show the image with for loop.
#foreach($plan as $plan)
{ !! html_entity_decode($plan->plan_image) !! }
or
{!! $plan->plan_image !! }
#endforeach
Not working. How can I resolve this?
Thanks
I think this is not the way to go with images and the database. This way you will have a very little space to do any kind of customization.
If your code is not working, you can always do {{ dd($plan->plan_image) }} and see what happens.
Also, you should stop using Blade's or and start using ?? PHP's native null coalesce operator.

Can't Display image in a webpage laravel 4

I have a image in the public/images folder.I want to show this image in my webpage and I am trying like this
{{ HTML::image('public/images/20140208-IMG_2538.jpg') }}
But I cant see my image on my webpage.Instead It shows a broken image icon.What can i do can anyone suggest?
The HTML::image() expects a path that is relative to public. Try this:
{{ HTML::image('images/20140208-IMG_2538.jpg') }}

Laravel Blade Highlight Change Tags

I am going to use AngularJS along with Laravel, and I wanted to change Laravel tags to [[ ]] (which I think BTW is nicer since [ ] looks more like blade and is sharper :p )
Anyhow, I changed it with
Blade::setContentTags('[[', ']]'); // for variables and all things Blade
Blade::setEscapedContentTags('[[[', ']]]'); // for escaped data
How do I change the "Bracket Highlight" in Sublime now so that it still highlights my new tags??
Not directly answerting your question, but my solution to have Angular and Blade playing nice is very simple, I create a _partial every time I need some Angular and name this partial just '.php' and not '.blade.php', so if I have a form that uses Angular, I have:
{{ Form::open() }}
#include('_partials.posts.forms.create');
{{ Form::close() }}
In this case the included file would be views/_partials/posts/forms/create.php.
About Sublime, download Blade Syntax Highlighter, this file might give you a clue about how to change that for you:
https://github.com/Medalink/laravel-blade/blob/master/laravel-blade.tmLanguage

Resources