2

I want to use css in my blade.php files but I am having trouble doing so. I would like to avoid using an external css sheet. In a normal html file I can do something like this

<img src="/Users/rays/Desktop/Icons/Joe_Icon.png" style="width:160px;height:100px">

And it will generate an image for me that is resized.I am trying to do the same thing in a blade file but am having trouble.

The following code displays an image but doesn't it style it to the right dimensions, I also see the words style="width:160px;height:100px" on the screen.

<a href="#">{{ HTML::image("progress2/Icons/Joe_Icon.png")}} style="width:160px;height:100px"  </a>

This also displays an image but doesn't display the image with the right size.

  <style="width:160px;height:100px">
  <a href="#">{{ HTML::image("progress2/Icons/Joe_Icon.png")}} </a>
  </style>

And the following gets me a syntax error

<a href="#">{{ HTML::image("progress2/Icons/Joe_Icon.png" style="width:160px;height:100px" )}} </a>

1 Answer 1

2

Try this one:

{!! HTML::image('progress2/Icons/Joe_Icon.png', 'alt', array( 'width' => 160, 'height' => 100 )) !!}

Also, hardcoding CSS is a bad practice. You should use CSS stylesheets and build images like this:

{!! HTML::image('progress2/Icons/Joe_Icon.png', 'alt', array('class' => 'progress_image')) !!}
Sign up to request clarification or add additional context in comments.

1 Comment

That worked thank you I had been struggling with this for a while

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.