hello,
i try to use the media colorbox with "file field" for images.
how can i config that the photos will be shown in correct dimensionen(height and lenght).
if i use "image fields" the dimensionen are correct in colorbox.
is that wrong config or issue?
Comments
Comment #1
checker commentedIf i'm using colorbox media as a file field and scalePhotos = true it is not working. The image is still bigger than the container around.
Comment #2
kmadel commentedWhere is the setting 'scalePhotos' coming from? I am not familiar with that setting.
Comment #3
checker commentedScalePhotos is a setting in colorbox plugin and by default = true (http://www.jacklmoore.com/colorbox).
To see how this effect works please go to http://www.jacklmoore.com/colorbox/example1/ and click on an example of "No Transition + fixed width and height (75% of screen size)". If you have a small web browser window the picture and overlay window have always a suitable size.
But media colorbox always shows native image sizes so the picture is cropped because the overlay window fits correctly.
This colorbox effect works without problems if you are using an image field instead of a file field for media colorbox. It could be related to #1514380: onclick event on img tag not working
Comment #4
kmadel commentedThis is actually not going to be that straightforward to support and would be a feature more than a support request. Media Colorbox always assumes that it is going to display the 'view mode' of a file entity to include any possible fields that may be included for the chosen view mode. For example, if you have added 3 fields to the Image File entity type and chosen all three of those fields to be displayed for the view mode chosen for the colorbox overlay output, then the you will have several HTML elements displayed as the Colorbox content and not just an image. So, you wouldn't be able to scale just the image and have everything fit if you had text fields to display as well. There may also be the case where you have several different file entity types (audio, video, and images) as part of the same file field and displayed as a gallery in the Colorbox - scalePhotos would not apply to the audio or video very well if at all. If you know what size you want your Colorbox to be, then just create a custom Image Style and apply to your chosen Colorbox display view mode for the image file type - this seems like a better approach to me anyways as artificial scaling of images in the browser is typically not the best approach for users with limited bandwidth or for general frontend performance.
Comment #5
jmix commentedHi, i have the same "feature request" ;-)
I understand here that this is outside of the scope of this module, but i can't find a way to do this:
- have a rendered thumbnail entity (for exemple image + description) as colorbox link
- when user clicks > overlay shows image only, with the colorbox "scale" feature
I guess this is not so hard to do this in view, but i need to do this at a node level.
I've tried lots of things with fields and display suite for example and i'm now searching to resolve this with template files where i could manually insert a link with colorbox-load class. But i can't find any file.tpl.php or equivalent. Any idea ?
Checker, have you found a solution to this ?
Thanks !
Comment #6
jmix commentedis there something i could do in media_colorbox.page.inc to force the output of normal image style in the overlay ?
Comment #7
kmadel commentedIf you are using the field formatter, then just set 'Dimensions' setting to be empty and the colorbox will resize to fit the image.
Comment #8
kmadel commentedWith RC2 the 'Dimensions' setting is gone for the field formatter settings. Now there are 'Fixed Width' and 'Fixed Height' settings, if you don't set these, then the Colorbox will resize to fit the image.
Comment #9
n20 commentedkmadel, i'm using RC3 of media_colorbox. My 'Fixed Width' & 'Fixed & Height' settings are empty but the colorbox don't resize correctly for images. Im using a field with mixed types (image & vimeo). For the Video, the Colorbox resize just fine. For the images wich are sometimes quite large (3072x1728) the colorbox appears with a vertical scrollbar. it seems that the colorbox is resizing, but only for the width.
Comment #10
murzHave the same problem. Is there any soltuion exists?
As I see, when colorbox shows normal image, it contains only image file, but with media field we have full html page, that located at /media_colorbox/[fid]/media_original/und
So we must resize image into it manually via some javascript or other way, but I can't find working method at now.
Comment #11
k3vin_nl commentedI have found some sort of workaround for this.
Basicly the issue is that colorbox has issues with URL's like 'media_colorbox/156/media_original/en'. It can't correctly determine (and thus scale) the dimensions of the image. I'm not sure if this is colorbox's or media module's 'fault', but it looks like the image is served with the incorrect mime type.
Anyway, a way to prevent this is to point to the URL of the actual image, instead of the media module's callback.
I did this in the theme_media_colorbox function:
After this resizing works correctly.
Cleaned up, the whole function then becomes:
Comment #12
k3vin_nl commentedComment #13
mpotter commentedThe theme function in #11 also fixed this problem for me. My images are correctly resized now. Before this function, only the width was resized. Thanks for posting this work-around!
Comment #14
proteo commented@K3vin:
Just created an account to thank you! Code from #11 effectively solved the problem, which had me pulling my hair for the past days trying to fix it myself with no success.
Now, this "feature" definitively should be added to the module, maybe as a configurable option, since one of the most common uses for ColorBox is displaying images, and right now that's just broken. It makes no sense!
Comment #15
sheise commented#11 worked for me as well.
It also fixed an issue I was having where some images had tiny heights in colorbox (this issue I think #1909030: Colorbox very, very small when clickin on image).
Thanks!
Comment #16
greg boggsThanks K3vin! The fix has been committed.
Comment #17
greg boggsI had to revert this commit as this theme override breaks the displaying of captions and other custom fields.
Comment #18
henrijs.seso commentedIt also brakes contextual links.