Changed mime type map to deal with the reality that certain file types have multiple extensions and/or multiple mime types, as well as constants supporting all of the data. Created new functions using the updated mime type map to resolve mime types and extensions. Updated various items around the project that determine mime/extension to take advantage of the new functions.
		
			
				
	
	
		
			36 lines
		
	
	
		
			996 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			996 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php declare(strict_types=1);
 | |
| 
 | |
| class FlashFileHandler extends DataHandlerExtension
 | |
| {
 | |
|     protected $SUPPORTED_MIME = [MIME_TYPE_FLASH];
 | |
| 
 | |
|     protected function media_check_properties(MediaCheckPropertiesEvent $event): void
 | |
|     {
 | |
|         $event->image->lossless = true;
 | |
|         $event->image->video = true;
 | |
|         $event->image->image = false;
 | |
| 
 | |
|         $info = getimagesize($event->file_name);
 | |
|         if ($info) {
 | |
|             $event->image->width = $info[0];
 | |
|             $event->image->height = $info[1];
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     protected function create_thumb(string $hash, string $type): bool
 | |
|     {
 | |
|         if (!Media::create_thumbnail_ffmpeg($hash)) {
 | |
|             copy("ext/handle_flash/thumb.jpg", warehouse_path(Image::THUMBNAIL_DIR, $hash));
 | |
|         }
 | |
|         return true;
 | |
|     }
 | |
| 
 | |
|     protected function check_contents(string $tmpname): bool
 | |
|     {
 | |
|         $fp = fopen($tmpname, "r");
 | |
|         $head = fread($fp, 3);
 | |
|         fclose($fp);
 | |
|         return in_array($head, ["CWS", "FWS"]);
 | |
|     }
 | |
| }
 |