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

Created on 22 January 2024, 5 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

Needs review

Version

2.5

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands pefferen

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024