image_tag seems to ignore the alt attribute

Hello there,

I’m using the image_tag helper to add images on the page, however it seems like the alt attribute is ignored.
Neither the code solutions below have not produced the expected output.

<%= image_tag 'title.jpg', :class => 'title', :alt => 'my title goes here' %>

<%= image_tag 'title.jpg', { :class => 'title', :alt => 'my title goes here' } %>

Only one parameter at a time seems to be included, the first one.

Can you please advice?
Thanks
Andrea

I haven’t seen this behavior on my projects. The image_tag helper dutifully adds classes and alt attributes for me. Can you provide any additional information about your local setup? What version of Middleman are you running? What else is on that page/layout?

Thanks for your feedback.

I’m running the latest version of MM, not sure the number but this has been recently installed (less than 2 weeks ago).

That said, which is the correct syntax I should use. I still believe I am doing some mistakes there.

Thanks
Andrea

Here’s an example that behaves as expected from my project:

<%=image_tag('img/picture.jpg', {alt: 'Example Text', class:'img-responsive img-thumbnail' }) %>

You should always be able to see the specific version of MM you’re using in your Gemfile.lock file.

Hi,

I have MiddleMan version 3.3.7.

I tried both these solutions

  <%= image_tag 'title.jpg', { :class => 'title1', :alt => 'test' }%>

  <%= image_tag('title.jpg', {class: 'title1', alt: 'test' }) %>

Class is outputted, but not the alt tag. What kind of details should I pass to you to dig into this matter?

Thanks
Andrea

Ok, found the problem. It’s within the code associated with this function

#activate :automatic_alt_tags

For whatever reason, this was overriding the setting.