I am trying to set up the Media Colorbox formatter to display my original images and let it scale them to fit the screen size. This works well with the original Colorbox formatter but I cannot get the desired behavior with this module. I am setting the "Colorbox view mode" drop-down to "Original". I have left the "Fixed Width" and "FIxed Height" fields blank. When I click on a gallery thumbnail Colorbox is displayed and takes up the entire screen space (as expected) but the image inside is not scaled down. It is instead left really "original" and scroll bars appear inside Colorbox.

How can I have the same behavior that the original Colorbox has - scale down the bigger images to fit the screen size?

Comments

kirilius’s picture

up

Kirk’s picture

I'm having the same issue. It seems that media_colorbox is not performing any calculations on the width and height attributes of the image to be displayed. As a result, the image's actual width and height are used. This is not how the normal colorbox works and I assume is not the intended behavior.

Chipie’s picture

Have you found a solution yet?

nodecode’s picture

Not sure if this is an option for everyone but I upgraded to 7.x-2.0 and it solved the problem right away. Don't forget to run update.php. There were no significant drawbacks to using the 2.0 upgrade that I could see and the database updates were error-free.

Chipie’s picture

What did you upgrade to 7.x-2.0? Ist here 7.x-2.0 version of Media Colorobx?

nodecode’s picture

Oops sorry. I forgot to mention that I was referring to upgrading the Colorbox plugin itself. Still using 7.x-1.0-rc3 of Media Colorbox.

robertom’s picture

I use:

Colorbox 7.x-2.0+2-dev
File entity 7.x-2.0-unstable7+3-dev
Media Colorbox 7.x-1.0-rc3

and the problem still exists

siretfeL’s picture

...it seems like we only have options to load images in original size not automatically resized as in usual colorbox or in preset image styles. Problem (;) remains with latest colorbox plugin and module (7.x-2.3). Could it be a configuration issue?

magic_al’s picture

Same here. Same configuration like #7.

magic_al’s picture

Alright, the thing is the Module looks at an image not as an image but rather as an file while the actual colorbox deals with an image in a slightly other way.

In case of the scaling problem the plugin just can't recognize the image as an image. It tries to check it:

function isImage(settings, url) {
                return settings.photo || settings.photoRegex.test(url);
}

settings.photoRegex.test(url) checks weather the reference ('href') of the link handed over to the plugin is an image or not. As the Module does not link to the image but to a Html document containing the image the argument is evaluated false.

As for the settings.photo variable: According to http://www.jacklmoore.com/colorbox/, the 'photo' setting is applyable in case that the URL of the image is evaluated false but still as an image. For example .../image.php would be evaluated to not be an image. In the present case the URL is not a image at all so this property dosn't help us.

magic_al’s picture

That works for me:

One has to adjust the image output. That means in case of an image the link is supposed to reference the real image instead of the file entity. I created a small module as follows:

function my_module_media_colorbox($variables) {
  global $base_url;
  $file_id = $variables['file_id'];
  $file = file_load($file_id);

  // if the file is an image set the path to the image path
  if($file->type == 'image') {
    $variables['path'] = $base_url . "/sites/default/files/" . $file->filename;
  }

  return theme_media_colorbox($variables);
}                                                                                                                                                                                                                                   

Hope it helps someone.

suldan’s picture

The parent has the correct width, so just force the image to stay inside. Maybe like:

#cboxLoadedContent img {
max-width:100% !important;
height:auto !important;
}

Edit: But then we probably get trouble with some crazy markups floating around ( #cboxTopLeft, #cboxTopRight, etc.) they are building the frame. Solution: don't use them.

andrey_sunday’s picture

Status: Closed (fixed) » Active
greg boggs’s picture

Status: Active » Closed (fixed)

Thanks Andrey!

I assumed the commit fixed this too, but I haven't had a chance to test it directly yet. Did you test my commit to make sure this bug is fixed? Feel free to update ticket status if you see any issues with the wrong status.

andrey_sunday’s picture

Yes, I tested your commit. Everything works fine. Thank you for the wonderful module.

suldan’s picture

Awesome! Ty for the commit!

andrey_sunday’s picture

Status: Active » Closed (fixed)