Close

Attachment Image html error

david.hirst
9 years ago
#9552 Quote
Avatar
  • 16
The image which you can specify to be displayed beside the attachment link on the public website creates an html img tag where the img src value is also specified for the alt text tag. This is a bit peculiar as it should really be alternate text to describe the image and not a URL! The plugin doesn't appear to have a specific alt txt field where you can specify it. If the plugin has to make something up it would be better to either use an empty string or base it on the name of the attachment rather than the URL of the image. 

e.g. for one of my attachments this is the code generated:

<img src="https://www.mysite.com/store/content/images/thumbs/0009249.png" alt="https://www.mysite.com/store/content/images/thumbs/0009249.png">
Deni
9 years ago
#9558 Quote
Avatar
  • Moderator
  • 389
david.hirst wrote:
The image which you can specify to be displayed beside the attachment link on the public website creates an html img tag where the img src value is also specified for the alt text tag. This is a bit peculiar as it should really be alternate text to describe the image and not a URL! The plugin doesn't appear to have a specific alt txt field where you can specify it. If the plugin has to make something up it would be better to either use an empty string or base it on the name of the attachment rather than the URL of the image. 

e.g. for one of my attachments this is the code generated:

<img src="https://www.mysite.com/store/content/images/thumbs/0009249.png" alt="https://www.mysite.com/store/content/images/thumbs/0009249.png">


Hi, 

Thanks for pointing out this. We just fix it in the plugin. 

If you do not want to wait for the deploy, you can easily fix it by yourself.
Go to this file: \Plugins\SevenSpikes.Nop.Plugins.Attachments\Views\ProductAttachment\_Attacments.cshtml and find this row: 
<img src="@attachment.ImageUrl" alt="@attachment.ImageUrl" />

Edit it like this:
<img src="@attachment.ImageUrl" alt="@attachment.Name" />


And this will show the name of the attachment as a alternative text.


P.S. Please let us know which version of nop you are using.
Best Regards,
Mladen Staykov
Nop-Templates.com
david.hirst
9 years ago
#9563 Quote
Avatar
  • 16
Hi,

Thanks for that. I'm now running NOPC v3_60 having updated from v3_50 yesterday.
I tried updating the code manually as you suggested but got the error "Compiler Error Message: CS1061: 'SevenSpikes.Nop.Plugins.Attachments.Models.AttachmentPublicModel' does not contain a definition for 'ImageName' and no extension method 'ImageName' accepting a first argument of type 'SevenSpikes.Nop.Plugins.Attachments.Models.AttachmentPublicModel' could be found (are you missing a using directive or an assembly reference?)" so have instead edited in a fixed string for now as you showed me where to do it. I will await the full plugin upgrade which I expect will sort this out.

Thanks.
Deni
9 years ago
#9564 Quote
Avatar
  • Moderator
  • 389
david.hirst wrote:
Hi,

Thanks for that. I'm now running NOPC v3_60 having updated from v3_50 yesterday.
I tried updating the code manually as you suggested but got the error "Compiler Error Message: CS1061: 'SevenSpikes.Nop.Plugins.Attachments.Models.AttachmentPublicModel' does not contain a definition for 'ImageName' and no extension method 'ImageName' accepting a first argument of type 'SevenSpikes.Nop.Plugins.Attachments.Models.AttachmentPublicModel' could be found (are you missing a using directive or an assembly reference?)" so have instead edited in a fixed string for now as you showed me where to do it. I will await the full plugin upgrade which I expect will sort this out.

Thanks.


Hi, 

The error says that you have wrote this:
<img src="@attachment.ImageUrl" alt="@attachment.ImageName" />


I wrote in my previous comment that the fix should look this way:
<img src="@attachment.ImageUrl" alt="@attachment.Name" />


I hope this helped!
Best Regards,
Mladen Staykov
Nop-Templates.com
david.hirst
9 years ago
#9565 Quote
Avatar
  • 16
Oops, yes, my mistake. Your version works!

Thanks again.