Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect width using Bootstrap 3 #15 #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

velizarov
Copy link

Need to double check. Maybe we can come up with something else to fix it

@grimmaceil
Copy link

grimmaceil commented Jan 19, 2017

The following completes the data-w and data-h without providing it from the back-end server. I have a case where folders are used as a storage for images and thumbnails but no other data about them is stored in a database or elsewhere. It would be way too server intensive to check the images every time. It would also take a while to also database the file information. It's easiest to off load to the client after the images are loaded. Then call $('#selectGallery').flexImages({ rowHeight: 140 }); This could probably be incorporated in to flex-images. (Thank you and nice work on flex-images!)

        // http://stackoverflow.com/questions/318630/get-the-real-width-and-height-of-an-image-with-javascript-in-safari-chrome
        // http://stackoverflow.com/questions/2358205/invoking-a-jquery-function-after-each-has-completed
        var itemCalbackCountDown = $('.item').length -1;
        $('.item').each(function () {
            var itm = $(this);
            $("<img/>") // Make in memory copy of image to avoid css issues
                .attr("src", itm.find("img").attr("src"))
                .load(function () {
                    itm.attr("data-w", this.width);
                    itm.attr("data-h", this.height);
                    // Note: $(this).width() will not work for in memory images.
                    // make the rows pretty This si
                    // needs to be done on the end of the last callback of this iteration 
                    if (!--itemCalbackCountDown) {
                        $('#selectGallery').flexImages({ rowHeight: 120 });
                    }
                }
                );
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants