File link icons are broken when the installation is under a subdirectory

Created on 23 December 2019, almost 5 years ago
Updated 22 January 2024, 10 months ago

When Social is installed under a domain's directory, ex. http://www.example.com/social/, the mimetype icons are broken whenever uploading a file in a node, post or comment.

This is due to a hard-coded / base path in file-link templates.

Steps to reproduce

  • Install OpenSocial under a domain's subdirectory, ex. /social
  • Create a new node, for example a Topic, at http://www.example.com/social/node/add/topic
  • In the Image field, upload an image. The file icon will appear to be missing since its path will be absolute to the parent domain like so:
    <span class="file-icon">
       <img class="node-file__icon" src="/profiles/contrib/social/themes/socialbase/assets/images/mime-icons/icon_1_image_x16.png" srcset="/profiles/contrib/social/themes/socialbase/assets/images/mime-icons/icon_1_image_x32.png 2x" alt="image">
    </span>
    
  • In the Attachments field, upload a file. The file icon will also appear to be missing. Its markup will be something like:
    <span class="file-icon">
      <img class="node-file__icon" src="/profiles/contrib/social/themes/socialbase/assets/images/mime-icons/icon_1_pdf_x16.png" srcset="/profiles/contrib/social/themes/socialbase/assets/images/mime-icons/icon_1_pdf_x32.png 2x" alt="pdf">
    </span>
    
  • Populate other required fields and save the node
  • The file links icons on the node page will also appear to be missing where the markup is like the following:
    <span class="card-file__type">
       <img class="card-file__icon" src="/profiles/contrib/social/themes/socialbase/assets/images/mime-icons/icon_1_pdf_x16.png" srcset="/profiles/contrib/social/themes/socialbase/assets/images/mime-icons/icon_1_pdf_x32.png 2x" alt="pdf">
      <span class="card-file__size">147.28 KB</span>
    </span>
    

The same thing happens in other use-cases, like when trying to upload an attachment to a comment (enable social_comment_upload module).

🐛 Bug report
Status

Closed: won't fix

Version

9.0

Component

Front-End

Created by

🇬🇷Greece epapaniko

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024