Hey Laraguys,
I am really new to Laravel, however I am enjoying my time alot by working with it. This might be the first question in a series of newb questions from me while im trying to learn this great framework.
Here goes:
Is there a better way to show my pictures inside my views than what is shown below (this is working btw)?
<?php echo "<img src='/images/articles/$article->image'>"?>
I tried doing it using blade, however I couldn't get it to work, since i'm not completely sure how to input the actual path to the images inside the Blade braces:
{{$article->image}}
I hope you can shed some light on this issue for me, since I really want to use Blade for all of my views thoroughly.
Thanks,
mrterryh said:
Try
Hi mrterryh,
Would I just add "images/mypath" insde the braces to get it to work?
Thanks!
There is also an HTML helper for images...
{{ HTML::image('images/mypath'.$article->image) }}
http://laravel.com/api/source-class-Illuminate.Html.HtmlBuilder.html#98-111
That did the trick! Thanks AndrewBNZ and mrterryh :)
Just to clarify the way that the blade syntax works:
{{ $article->image }}
is just a replacement for:
<?php echo $article->image; ?>
therefore you don't need to include the echo part if you are outputting HTML; that's part of what blade does for you. For example in your example you would do the following:
<img src="/images/mypath/{{ $article->image }}">
which is translated to
<img src="/images/mypath/<?php echo $article->image; ?>">
behind the scenes.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community