Support the ongoing development of Laravel.io →
Views Blade Forms

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,

  • Casper.
Last updated 3 years ago.
0

Try

<img src="{{ $article->image }}" />
Last updated 3 years ago.
0

mrterryh said:

Try

Hi mrterryh,

Would I just add "images/mypath" insde the braces to get it to work?

Thanks!

Last updated 3 years ago.
0

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

Last updated 3 years ago.
0

That did the trick! Thanks AndrewBNZ and mrterryh :)

Last updated 3 years ago.
0

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.

Last updated 3 years ago.
0

Thanks for clarifying citricsquid!

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Reached reached Joined 27 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.