Just noticed within this forum regarding uploaded files this issue. Is it designed intentionally this way?

7 posts by 4 authors in: Forums > CMS Builder
Last Post: July 23, 2024   (RSS)

By Codee - July 19, 2024

As I was reviewing this forum I noticed an interesting effect. If I click on an attached file, the "target" is different depending upon the file type. If the uploaded attachment is a .jpg or .png the mouse click opens up in the same window. If I click on an attachment that is a .webp it opens in a new window.  Is this by design?

By TimHurd - July 20, 2024

Hi Codee,

I noticed that the server is sending webp files as an incorrect mimetype of

application/octet-stream

instead of being image/webp. Think of mimetypes as a way for a server to tell a browser the type of file it is. This means when the browser encounters such a file it will do something different than other file types. Some browsers will just download the file (which seems to be the default for Chrome) while others will open it in a new tab (which seems to be the default for Firefox). 

I think the solution here is for the server to make sure it is serving webp files with the correct mimetype. It is probably not this way by design and needs a simple mimetype association on the web server to fix it. It is nothing wrong on your side. 

I think you caught a nice little oddity here. :)

Tim Hurd
Senior Application Developer
TimHurd.com

By kitsguru - July 20, 2024

I believe that is caused by a browser setting. Check your settings on how each file type is handled.

Jeff Shields
yaadev.com

By Codee - July 21, 2024

Thanks, Jeff. 

By Codee - July 21, 2024

Tim,

Thank you for jumping in and addressing my post quickly, accurately and effectively. I appreciate not only you and Jeff, but the entire IT team led by Mr. Dave. 

By Dave - July 23, 2024

Hi All,

Thanks for noticing this and for all the feedback and insights.  

I added the mimetype to the simpleForum.php function sforum_downloadForumAttachment() as follows: 

  // get content-type for showing files inline
  $inlineExtToHeader = array(
    'gif'  => 'image/gif',
    'jpg'  => 'image/jpeg',
    'jpeg' => 'image/jpeg',
    'png'  => 'image/png',
    'webp' => 'image/webp',
  );

So webp files should display inline now without forcing you to download them.

Thanks!

Dave Edis - Senior Developer
interactivetools.com