1
0
mirror of https://github.com/misterunknown/ifm.git synced 2025-08-09 09:36:29 +02:00

fix problem with image preview when the path contains special characters

This commit is contained in:
Marco Dickert
2017-08-05 02:19:12 +02:00
parent 44cc585fa4
commit 6a45ae38fa
3 changed files with 30 additions and 33 deletions

View File

@@ -1149,8 +1149,9 @@ function IFM( params ) {
item.download.action = "download";
item.download.icon = "icon icon-download";
}
if( item.icon.indexOf( 'file-image' ) !== -1 && self.config.isDocroot )
item.tooltip = 'data-toggle="tooltip" title="<img src=\'' + self.HTMLEncode( self.pathCombine( self.currentDir, item.name ) ) + '\' class=\'imgpreview\'>"';
if( item.icon.indexOf( 'file-image' ) !== -1 && self.config.isDocroot ) {
item.tooltip = 'data-toggle="tooltip"';
}
if( self.config.extract && self.inArray( item.ext, ["zip","tar","tgz","tar.gz","tar.xz","tar.bz2"] ) ) {
item.eaction = "extract";
item.button.push({
@@ -1246,6 +1247,13 @@ function IFM( params ) {
});
// has to be jquery, since this is a bootstrap feature
$( 'a[data-toggle="tooltip"]' ).tooltip({
title: function() {
var item = self.fileCache.find( x => x.guid == $(this).attr('id') );
var tooltip = document.createElement( 'img' );
tooltip.src = encodeURI( self.pathCombine( self.currentDir, item.name ) ).replace( '#', '%23' ).replace( '?', '%3F' );
tooltip.classList.add( 'imgpreview' );
return tooltip;
},
animated: 'fade',
placement: 'right',
html: true
@@ -2261,15 +2269,6 @@ function IFM( params ) {
}
};
/**
* Encodes a string to use in HTML attributes
*
* @param string s - decoded string
*/
this.HTMLEncode = function( s ) {
return s.replace( /'/g, '&#39;').replace( /"/g, '&#43;');
};
/**
* Encodes a string for use in the href attribute of an anchor.
*

21
ifm.php
View File

@@ -1149,8 +1149,9 @@ function IFM( params ) {
item.download.action = "download";
item.download.icon = "icon icon-download";
}
if( item.icon.indexOf( 'file-image' ) !== -1 && self.config.isDocroot )
item.tooltip = 'data-toggle="tooltip" title="<img src=\'' + self.HTMLEncode( self.pathCombine( self.currentDir, item.name ) ) + '\' class=\'imgpreview\'>"';
if( item.icon.indexOf( 'file-image' ) !== -1 && self.config.isDocroot ) {
item.tooltip = 'data-toggle="tooltip"';
}
if( self.config.extract && self.inArray( item.ext, ["zip","tar","tgz","tar.gz","tar.xz","tar.bz2"] ) ) {
item.eaction = "extract";
item.button.push({
@@ -1246,6 +1247,13 @@ function IFM( params ) {
});
// has to be jquery, since this is a bootstrap feature
$( 'a[data-toggle="tooltip"]' ).tooltip({
title: function() {
var item = self.fileCache.find( x => x.guid == $(this).attr('id') );
var tooltip = document.createElement( 'img' );
tooltip.src = encodeURI( self.pathCombine( self.currentDir, item.name ) ).replace( '#', '%23' ).replace( '?', '%3F' );
tooltip.classList.add( 'imgpreview' );
return tooltip;
},
animated: 'fade',
placement: 'right',
html: true
@@ -2261,15 +2269,6 @@ function IFM( params ) {
}
};
/**
* Encodes a string to use in HTML attributes
*
* @param string s - decoded string
*/
this.HTMLEncode = function( s ) {
return s.replace( /'/g, '&#39;').replace( /"/g, '&#43;');
};
/**
* Encodes a string for use in the href attribute of an anchor.
*

View File

@@ -118,8 +118,9 @@ function IFM( params ) {
item.download.action = "download";
item.download.icon = "icon icon-download";
}
if( item.icon.indexOf( 'file-image' ) !== -1 && self.config.isDocroot )
item.tooltip = 'data-toggle="tooltip" title="<img src=\'' + self.HTMLEncode( self.pathCombine( self.currentDir, item.name ) ) + '\' class=\'imgpreview\'>"';
if( item.icon.indexOf( 'file-image' ) !== -1 && self.config.isDocroot ) {
item.tooltip = 'data-toggle="tooltip"';
}
if( self.config.extract && self.inArray( item.ext, ["zip","tar","tgz","tar.gz","tar.xz","tar.bz2"] ) ) {
item.eaction = "extract";
item.button.push({
@@ -215,6 +216,13 @@ function IFM( params ) {
});
// has to be jquery, since this is a bootstrap feature
$( 'a[data-toggle="tooltip"]' ).tooltip({
title: function() {
var item = self.fileCache.find( x => x.guid == $(this).attr('id') );
var tooltip = document.createElement( 'img' );
tooltip.src = encodeURI( self.pathCombine( self.currentDir, item.name ) ).replace( '#', '%23' ).replace( '?', '%3F' );
tooltip.classList.add( 'imgpreview' );
return tooltip;
},
animated: 'fade',
placement: 'right',
html: true
@@ -1230,15 +1238,6 @@ function IFM( params ) {
}
};
/**
* Encodes a string to use in HTML attributes
*
* @param string s - decoded string
*/
this.HTMLEncode = function( s ) {
return s.replace( /'/g, '&#39;').replace( /"/g, '&#43;');
};
/**
* Encodes a string for use in the href attribute of an anchor.
*