When implementing simple Image CB I have found a number of bugs (I believe). They are mostly related to non-cropped images (cropped ones are working fine).
When uploaded image pixel size exceeds contentblocks.image.max_upload_height or contentblocks.image.max_upload_width it is rescaled to these max values and saved (as expected), but [[+width]] and [[+height]] placeholders in field template are set to original image size (which is not true anymore)
When I choose from already uploaded images using media browser and image exceeds 800x600px, [[+width]] and [[+height]] placeholders are set to maximum 800x600px (respecting original image aspect ratio). What the heck is 800x600 these days anyway?
When setting Manager thumbnail size in Image field definition (thus trying to use phpthumb for preview), preview in manager is broken, though everything else is working fine, both back-end and front-end. Even temporary preview while uploading is showing fine, but disappears after upload. This is due to media source basePath added to src parameter in phpthumb call. I know I can try changing media source settings to use absolute urls/paths. I am afraid this can break other working components. Using crops for manager thumb works fine as well, but I don’t want force users to use cropper.
Really can’t make this working. Any ideas? I consider all these as bugs. It forces us to use always crops, which is annoying for users (crops work fine, but don’t make default crop without user intervention as I noted in another post).
According third point:
In contrast to image Template Variables, which stores only path relative to Media source basePath (that means without basePath part) and adds that basePath on TV output, CB image type stores entire path, including basePath. This is fine on CB output (you have correct path in [[+url]] placeholder) but breaks manager preview. Call to phpthumb must be without basePath part.
I’ve fixed the width/height being calculated before the resize only for 1.15.0-rc2.
The only 800x600 I can find is in the MODX core, as the default size for the thumb in the media browser. The size of that thumbnail should not have any effect on the actually selected image, that’s just how it gets previewed in the MODX browser. The image size placeholders are set from the actual source file.
Is this on 1.15.0-rc1? That should have resolved issues with the thumb in the manager not showing when it belongs to a different media source than the default.
If it’s still happening for you on 1.15.0-rc1 please provide details about your image field and media source configuration so I can follow along to try and reproduce the problem.
System settings:
default_media_source: 1
setting_contentblocks.image.source: 1
setting_contentblocks.image.max_upload_height: 4096
setting_contentblocks.image.max_upload_width: 4096
Test content block of type “Image with title”:
Template: <img src="[[+url]]" width="[[+width]]" height="[[+height]]" alt="[[+alt]]" title="[[+title]]">
Media source override: None
Directory: images/_contentblocks
Crops: (none)
Manager Thumbnail Size: 150x100
Test image: image.jpg 6000x4000
Results:
image dropped to CB, uploaded correctly to /home/testproject/www/_user/images/_contentblocks/image.jpg, rescaled to 4096x2731
Resulting html: <img src="_user/images/_contentblocks/image.jpg" width="6000" height="4000" alt="" title="">
Incorrect size may change in rc2
image deleted and chosen from already uploaded files. Resulting html: <img src="_user/images/_contentblocks/image.jpg" width="800" height="533" alt="" title="">
As Mark noted, 800x600 is defined in /core/src/Revolution/Sources/modMediaSource.php for filemanager_image_width and filemanager_image_height. If I create system setting filemanager_image_width with value 1000, resulting html changes (after deleting and re-choosing already uploaded image) accordingly to: <img src="_user/images/_contentblocks/image.jpg" width="1000" height="667" alt="" title="">
So you somehow retain image preview size when picking from media browser.
In both previous cases manager thumb is broken, with incorrect call: https://myhost/connectors/system/phpthumb.php?src=/_user/images/_contentblocks/image.jpg&w=150&h=100&zc=1&source=1
Correct call should have src without Media source basePath /_user/: https://myhost/connectors/system/phpthumb.php?src=images/_contentblocks/image.jpg&w=150&h=100&zc=1&source=1
This is default media source and everything else is working fine. Image TVs, images inside TinyMCE, Media Browser and other manager previews, CB cropped images and MoreGallery as well.
Leaving Manager Thumbnail Size empty helps, but it loads entire big image into manager, not a good idea.
Okay it looks like #2 is a 2.x vs 3.x issue. On 2.x, the image_width and image_height would return the original image size. On 3.x, that changed and now returns the filemanager size.
3.x does add a new original_width/height so we need to use that. It looks straightforward enough to use that and fall back to the image_width/height if it’s not set (on 2.x), so consider that fixed in 1.15.0-rc2 as well.
Still need to research why the media source thing doesn’t work (#3)… will review that hopefully tomorrow.