Fixed Set attribute in [ATTACH alt="..."] to filename instead of attachment_id

Steffen

Well-known member
Affected version
2.1.0
When you upload an image and insert it into your post then XenForo sets its alt attribute (BB code as well as HTML) to the attachment_id. The result is that all newly uploaded attachments have useless numeric alt attributes. This does not make any sense to me. It furthermore seems bad for SEO (in contrast to the attachment_id, the filename usually contains at least some useful information). Am I missing something?

Example (filename "800px-Big_buck_bunny_poster_big.jpg" is replace by "195039"):

195039

Unless I'm missing something, could you please use the filename as the value for the alt attribute?

Diff:
--- a/js/xf/attachment_manager.js
+++ b/js/xf/attachment_manager.js
@@ -494,7 +494,7 @@

                 if (type == 'image')
                 {
-                    html = '<img src="{{img}}" data-attachment="full:{{id}}" alt="{{id}}" />';
+                    html = '<img src="{{img}}" data-attachment="full:{{id}}" alt="{{img.alt}}" />';
                 }
                 else
                 {
@@ -511,7 +511,7 @@
                 }

                 bbCode = '[ATTACH]' + attachmentId + '[/ATTACH]';
-                html = '<img src="{{img}}" data-attachment="thumb:{{id}}" alt="{{id}}" />';
+                html = '<img src="{{img}}" data-attachment="thumb:{{id}}" alt="{{img.alt}}" />';
             }

             html = Mustache.render(html, params);
 
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.1).

Change log:
Don't set a default alt when inserting an attachment into the rich text editor. (If no alt is present, when rendered, it will default to the filename.)
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Top Bottom