In order to resolve this issue, you can set the line-height using CSS for the specific element:
#file {
line-height: 37px;
}
If you prefer to achieve this using jQuery, you can do the following:
$('#file').css('line-height', $('#file').height() + 'px');
Regarding the initial problem description, it seems a clear question was not provided.
Additional Tip:
To address the initial concern, follow these steps:
var wrapper = $('<div/>').css({height:0,width:0,'overflow':'hidden'});
var fileInput = $(':file').wrap(wrapper);
fileInput.change(function(){
readURL(this);
})
$('#file').click(function(){
fileInput.click();
}).show();
function readURL(input) {
$('#blah').hide();
if (input.files && input.files[0]) {
var goUpload = true;
var uploadFile = input.files[0];
if (!(/\.(gif|jpg|jpeg|tiff|png)$/i).test(uploadFile.name)) {
$('#file').effect( "shake" );
$('#file').text('You must select an image file only');
setTimeout(function() { $('#file').text('Choose file');},5000);
goUpload = false;
}
if (uploadFile.size > 2000000) { // 2mb
//common.notifyError('Please upload a smaller image, max size is 2 MB');
$('#file').text('Please upload a smaller image, max size is 2 MB');
setTimeout(function() { $('#file').text('Choose file');},5000);
goUpload = false;
}
if (goUpload) {
$('#file').text("Uploading "+uploadFile.name);
var reader = new FileReader();
reader.onload = function (e) {
var img = new Image;
img.onload = function() {
var maxWidth = 100;
var maxHeight = 100;
var ratio = 0;
var width = this.width;
var height = this.height;
if (width > maxWidth) {
ratio = maxWidth / width;
$('#blah').css("width", maxWidth);
$('#blah').css("height", height * ratio);
height = height * ratio;
}
if (height > maxHeight) {
ratio = maxHeight / height;
$('#blah').css("height", maxHeight);
$('#blah').css("width", width * ratio);
width = width * ratio;
}
$('#blah').attr('src', this.src).show();
$('#file').text(uploadFile.name);
};
img.src = reader.result;
}
reader.readAsDataURL(uploadFile);
}
}
}
It's advisable to avoid duplicate lines like:
47 var width = uploadFile.width();
48 var height = uploadFile.height();
since they negate the previous actions.
Additionally, utilize FileReader() in conjunction with creating an Image Object for optimal results.