JQuery: How to get and set image width and height for a jQuery fancybox image?
-
_showWhenLoaded: function(index, callback) { if(this.images[index]) { var context = this; var image = this.images[index]; var img_container = $(document.createElement('div')).addClass('ad-image'); var img = $(new Image()).attr('src'=image.image); this is the code in http://jquery.ad-gallery.js ... need to set image width and height as attributes.. how to get image dimensions?
-
Answer:
May this ans help you.Ask your programming question on http://stackoverflow.com/questions http://stackoverflow.com/questions/15033964/send-height-and-width-to-fancybox-from-an-image-click beforeShow: function () { this.width = $(this.element).data("width"); this.height = $(this.element).data("height"); } http://jsfiddle.net/AWpcz/
Shree Khanal at Quora Visit the source
Other answers
Generate a temporary img element with src as image path and get width on load event. var image = this.images[index]; var width, height; $("<img/>") .attr("src", image.image ) .load(function() { width = this.width; height = this.height; }); Refer : http://stackoverflow.com/questions/318630/get-real-image-width-and-height-with-javascript-in-safari-chrome and https://api.jquery.com/load-event/#load-handler
Pranav C Ramanthali
Related Q & A:
- How To Set Image Generator?Best solution by wiki.openwrt.org
- How to set image for tabbar?Best solution by Stack Overflow
- How to get mobile scrollbar width?Best solution by Stack Overflow
- How to get rid of bulk mail that is truly a pain?Best solution by Yahoo! Answers
- How to get rid of a swollen eye due to a cut?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.