The resize is set "TRUE;" by default but when I click on an image with has the autoload class the image resize is tiny and i get horizontal and vertical scrollbars. The second time i view that image it works fine.

Comments

tronathan’s picture

This appears to be something related to loading the image.

If the image is not loaded in the browsers cache when the modal is called, this can occur.

To fix, I added the image to the containing page in an invisible div. This causes the image to load into the browsers cache on page load. This makes the pages heavier but appears to fix the problem.

When the user clicks the automodal link to display the image, the image is already cached. The image then displays correctly in the automodal.

Apparently the JS is not waiting until the image is actually loaded before determining the size to resize to, and therefore resizes to the smallest size possible.

The automodal size detection needs to wait longer, perhaps for a document.ready(), before resizing.

Anonymous’s picture

interesting solution . I am going to try this out. I have about 25 images on the page and will have to test it for speed time.

Thanks

Anonymous’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dennis605’s picture

I know that's not the correct way, but i did it this way:

In my automodal.js I inserted after:

Drupal.behaviors.automodal = function (context) {
    $.each(Drupal.settings.automodal, function(selector, settings) {
      $(selector +':not(.automodal-processed)', context)
        .addClass('automodal-processed')
        .bind('click', function() {
          settings.url = $(this).attr('href') || '#';
          if (settings.url.indexOf('?') >= 0) {
            settings.url += '&'
          }
          else {
            settings.url += '?'
          }
          settings.url += 'automodal=true';

          // Allow others to alter the settings as needed.
          settings = Drupal.automodal.settingsAlterCall(settings);

          settings.onSubmit = Drupal.automodal.onSubmitCall;
          Drupal.modalFrame.open(settings);

this:

$('.ui-dialog').resizable({
      alsoResize: '#modalframe-element, #modalframe-container',
      handles: 'e, w, sw, se, s',
    });

The whole code looks like that then:

Drupal.behaviors.automodal = function (context) {
    $.each(Drupal.settings.automodal, function(selector, settings) {
      $(selector +':not(.automodal-processed)', context)
        .addClass('automodal-processed')
        .bind('click', function() {
          settings.url = $(this).attr('href') || '#';
          if (settings.url.indexOf('?') >= 0) {
            settings.url += '&'
          }
          else {
            settings.url += '?'
          }
          settings.url += 'automodal=true';

          // Allow others to alter the settings as needed.
          settings = Drupal.automodal.settingsAlterCall(settings);

          settings.onSubmit = Drupal.automodal.onSubmitCall;
          Drupal.modalFrame.open(settings);
          $('.ui-dialog').resizable({
      alsoResize: '#modalframe-element, #modalframe-container',
      handles: 'e, w, sw, se, s',
    });
          return false;
        });
    });
  }

This's working perfect for me.

modctek’s picture

The suggested change in #5 broke automodal for me. Perhaps something has changed in jQuery?