Resize Screenshots

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
smlp
Posts: 14
Joined: 09 Jan 2007, 11:10

Resize Screenshots

Post by smlp »

We have Mantis confgured that attached screenshots are automatically displayed in the bug page.

But out users tend to attach large screenshots, I would like mantis resize them automatically if they're above a specified resolution (I think this can be done with width/height attributes of the img tag).

Someone knows if this is already included in Mantis or an easy way to do it?


Regards,

Sebastian
Narcissus
Developer
Posts: 338
Joined: 17 Feb 2005, 09:45

Post by Narcissus »

I don't think that there's a setting for that exactly, but you can set Mantis to not show attachments inline once they are bigger than a certain size on disk.

You can set $g_preview_attachments_inline_max_size in your config_inc.php file to do this.
smlp
Posts: 14
Joined: 09 Jan 2007, 11:10

Post by smlp »

This can easily be done by modifying the file_list_attachments function of file_api.php and adding a "width" attribute to the <img> tag.

It would be nice if you could add something like this to the code and add the width as a parameter to the config.

Here is a patch for Mantis 1.0.5 that scales the displayed image to 800 pixel width:

Code: Select all

*** file_api.php.bak	Tue Mar  6 17:31:32 2007
--- file_api.php	Tue Mar  6 17:31:32 2007
***************
*** 188,194 ****
  				( $v_filesize != 0 ) &&
  				( in_array( strtolower( file_get_extension( $t_file_display_name ) ), array( 'png', 'jpg', 'jpeg', 'gif', 'bmp' ), true ) ) ) {
  
! 				PRINT "<br /><img src=\"file_download.php?file_id=$v_id&type=bug\" />";
  				$image_previewed = true;
  			}
  
--- 188,194 ----
  				( $v_filesize != 0 ) &&
  				( in_array( strtolower( file_get_extension( $t_file_display_name ) ), array( 'png', 'jpg', 'jpeg', 'gif', 'bmp' ), true ) ) ) {
  
! 				PRINT "<br /><img width=\"800\" src=\"file_download.php?file_id=$v_id&type=bug\" />";
  				$image_previewed = true;
  			}
  

Post Reply