Make crop editor usable #22
@ -116,8 +116,15 @@ class EditAsset extends HTMLController
 | 
			
		||||
			if (!preg_match('~^(?<width>\d+)x(?<height>\d+)(?<suffix>_c(?<method>[best]?))?$~', $selector, $thumb))
 | 
			
		||||
				continue;
 | 
			
		||||
 | 
			
		||||
			// Does the thumbnail exist on disk? If not, use an url to generate it.
 | 
			
		||||
			if (!$filename || !file_exists(THUMBSDIR . '/' . $subdir . '/' . $filename))
 | 
			
		||||
				$thumb_url = BASEURL . '/thumbnail/' . $image->getId() . '/' . $thumb['width'] . 'x' . $thumb['height'] . $thumb['suffix'] . '/';
 | 
			
		||||
| 
					
	
	
	
	
	
	
	
	 
					
					Aaron marked this conversation as resolved
					
				 
				 | 
			||||
			else
 | 
			
		||||
				$thumb_url = THUMBSURL . '/' . $subdir . '/' . $filename;
 | 
			
		||||
 | 
			
		||||
			$has_crop_boundary = isset($metadata['crop_' . $thumb['width'] . 'x' . $thumb['height']]);
 | 
			
		||||
			$has_custom_image = isset($metadata['custom_' . $thumb['width'] . 'x' . $thumb['height']]);
 | 
			
		||||
 | 
			
		||||
			$thumbs[] = [
 | 
			
		||||
				'dimensions' => [(int) $thumb['width'], (int) $thumb['height']],
 | 
			
		||||
				'cropped' => !$has_custom_image && (!empty($thumb['suffix']) || $has_crop_boundary),
 | 
			
		||||
@ -125,9 +132,7 @@ class EditAsset extends HTMLController
 | 
			
		||||
				'crop_region' => $has_crop_boundary ? $metadata['crop_' . $thumb['width'] . 'x' . $thumb['height']] : null,
 | 
			
		||||
				'custom_image' => $has_custom_image,
 | 
			
		||||
				'filename' => $filename,
 | 
			
		||||
				'full_path' => THUMBSDIR . '/' . $subdir . '/' . $filename,
 | 
			
		||||
				'url' => THUMBSURL . '/' . $subdir . '/' . $filename,
 | 
			
		||||
				'status' => file_exists(THUMBSDIR . '/' . $subdir . '/' . $filename),
 | 
			
		||||
				'url' => $thumb_url,
 | 
			
		||||
			];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	
Edge case:
suffixcan be null, as the group is optional in the regex. Handle this.