Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
ce4c7897
Commit
ce4c7897
authored
11 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Image always fit into window when using cropping feature even if
file is a very large file.
parent
3030c2f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/core/js/lib_photosresize.js
+14
-8
14 additions, 8 deletions
htdocs/core/js/lib_photosresize.js
htdocs/core/photos_resize.php
+48
-40
48 additions, 40 deletions
htdocs/core/photos_resize.php
with
62 additions
and
48 deletions
htdocs/core/js/lib_photosresize.js
+
14
−
8
View file @
ce4c7897
// Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
// Copyright (C) 2009
-2014
Laurent Destailleur <eldy@users.sourceforge.net>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
...
...
@@ -19,23 +19,29 @@
// \brief File that include javascript functions for croping feature
//
/* Enable jcrop plugin onto id cropbox */
jQuery
(
function
()
{
jQuery
(
'
#cropbox
'
).
Jcrop
({
onSelect
:
updateCoords
,
onChange
:
updateCoords
});
});
/* Update fields that store new size */
function
updateCoords
(
c
)
{
jQuery
(
'
#x
'
).
val
(
c
.
x
);
jQuery
(
'
#y
'
).
val
(
c
.
y
);
jQuery
(
'
#x2
'
).
val
(
c
.
x2
);
jQuery
(
'
#y2
'
).
val
(
c
.
y2
);
jQuery
(
'
#w
'
).
val
(
c
.
w
);
jQuery
(
'
#h
'
).
val
(
c
.
h
);
//alert(parseInt(jQuery("#ratioforcrop").val()));
ratio
=
1
;
if
(
parseInt
(
jQuery
(
"
#ratioforcrop
"
).
val
())
>
0
)
ratio
=
parseInt
(
jQuery
(
"
#ratioforcrop
"
).
val
());
jQuery
(
'
#x
'
).
val
(
Math
.
ceil
(
c
.
x
*
ratio
));
jQuery
(
'
#y
'
).
val
(
Math
.
ceil
(
c
.
y
*
ratio
));
jQuery
(
'
#x2
'
).
val
(
Math
.
ceil
(
c
.
x2
*
ratio
));
jQuery
(
'
#y2
'
).
val
(
Math
.
ceil
(
c
.
y2
*
ratio
));
jQuery
(
'
#w
'
).
val
(
Math
.
ceil
(
c
.
w
*
ratio
));
jQuery
(
'
#h
'
).
val
(
Math
.
ceil
(
c
.
h
*
ratio
));
};
/* checkCoords */
function
checkCoords
()
{
if
(
parseInt
(
jQuery
(
'
#w
'
).
val
()))
return
true
;
...
...
This diff is collapsed.
Click to expand it.
htdocs/core/photos_resize.php
+
48
−
40
View file @
ce4c7897
...
...
@@ -128,11 +128,8 @@ if ($mesg) print '<div class="error">'.$mesg.'</div>';
$infoarray
=
dol_getImageSize
(
$dir
.
"/"
.
urldecode
(
$_GET
[
"file"
]));
$height
=
$infoarray
[
'height'
];
$width
=
$infoarray
[
'width'
];
print
$langs
->
trans
(
"CurrentInformationOnImage"
)
.
':'
;
print
'<ul>
<li>'
.
$langs
->
trans
(
"Width"
)
.
': '
.
$width
.
' px</li>
<li>'
.
$langs
->
trans
(
"Height"
)
.
': '
.
$height
.
' px</li>
</ul>'
;
print
$langs
->
trans
(
"CurrentInformationOnImage"
)
.
': '
;
print
$langs
->
trans
(
"Width"
)
.
': <strong>'
.
$width
.
'</strong> x '
.
$langs
->
trans
(
"Height"
)
.
': <strong>'
.
$height
.
'</strong><br>'
;
print
'<br>'
.
"
\n
"
;
...
...
@@ -142,55 +139,66 @@ print '<form name="redim_file" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" meth
print
'<fieldset id="redim_file">'
;
print
'<legend>'
.
$langs
->
trans
(
"Resize"
)
.
'</legend>'
;
print
$langs
->
trans
(
"ResizeDesc"
)
.
'<br>'
;
print
$langs
->
trans
(
"NewLength"
)
.
': <input class="flat" name="sizex" size="10" type="text" > px
<br>
'
;
print
$langs
->
trans
(
"NewLength"
)
.
': <input class="flat" name="sizex" size="10" type="text" > px
'
.
$langs
->
trans
(
"or"
)
.
'
'
;
print
$langs
->
trans
(
"NewHeight"
)
.
': <input class="flat" name="sizey" size="10" type="text" > px <br>'
;
print
'<input type="hidden" name="file" value="'
.
$_GET
[
'file'
]
.
'" />'
;
print
'<input type="hidden" name="action" value="confirm_resize" />'
;
print
'<input type="hidden" name="product" value="'
.
$id
.
'" />'
;
print
'<input type="hidden" name="id" value="'
.
$id
.
'" />'
;
print
'<br><input class="button" name="sendit" value="'
.
dol_escape_htmltag
(
$langs
->
trans
(
"Resize"
))
.
'" type="submit" />'
;
print
'</fieldset>'
;
print
'<br></form>'
;
print
'</fieldset>'
.
"
\n
"
;
print
'</form>'
;
print
'<br>'
.
"
\n
"
;
/*
*
Recadrage d'une
image
*
Crop
image
*/
print
'<br>'
.
"
\n
"
;
if
(
!
empty
(
$conf
->
use_javascript_ajax
))
{
$infoarray
=
dol_getImageSize
(
$dir
.
"/"
.
urldecode
(
$_GET
[
"file"
]));
$height
=
$infoarray
[
'height'
];
$width
=
$infoarray
[
'width'
];
print
'<!-- Form to crop -->'
.
"
\n
"
;
print
'<fieldset id="redim_file">'
;
print
'<legend>'
.
$langs
->
trans
(
"Recenter"
)
.
'</legend>'
;
print
$langs
->
trans
(
"DefineNewAreaToPick"
)
.
'...<br>'
;
print
'<br><center>'
;
print
'<div style="border: 1px solid #888888; width: '
.
$width
.
'px;"><img src="'
.
DOL_URL_ROOT
.
'/viewimage.php?modulepart=product&entity='
.
$object
->
entity
.
'&file='
.
$original_file
.
'" alt="" id="cropbox" /></div>'
;
print
'</center><br>'
;
print
'<form action="'
.
$_SERVER
[
"PHP_SELF"
]
.
'?id='
.
$id
.
'" method="post" onsubmit="return checkCoords();">
<div class="jc_coords">
'
.
$langs
->
trans
(
"NewSizeAfterCropping"
)
.
':
<label>X1 <input type="text" size="4" id="x" name="x" /></label>
<label>Y1 <input type="text" size="4" id="y" name="y" /></label>
<label>X2 <input type="text" size="4" id="x2" name="x2" /></label>
<label>Y2 <input type="text" size="4" id="y2" name="y2" /></label>
<label>W <input type="text" size="4" id="w" name="w" /></label>
<label>H <input type="text" size="4" id="h" name="h" /></label>
</div>
<input type="hidden" id="file" name="file" value="'
.
urlencode
(
$original_file
)
.
'" />
<input type="hidden" id="action" name="action" value="confirm_crop" />
<input type="hidden" id="product" name="product" value="'
.
$id
.
'" />
<input type="hidden" name="id" value="'
.
$id
.
'" />
<br><input type="submit" class="button" value="'
.
dol_escape_htmltag
(
$langs
->
trans
(
"Recenter"
))
.
'" />
</form>'
;
print
'</fieldset>'
;
$infoarray
=
dol_getImageSize
(
$dir
.
"/"
.
urldecode
(
$_GET
[
"file"
]));
$height
=
$infoarray
[
'height'
];
$width
=
$infoarray
[
'width'
];
$widthforcrop
=
$width
;
$refsizeforcrop
=
'orig'
;
$ratioforcrop
=
1
;
if
(
!
empty
(
$_SESSION
[
'dol_screenwidth'
])
&&
(
$widthforcrop
>
round
(
$_SESSION
[
'dol_screenwidth'
]
/
2
)))
{
$widthforcrop
=
min
(
round
(
$_SESSION
[
'dol_screenwidth'
]
/
2
),
$widthforcrop
);
$refsizeforcrop
=
'screenwidth'
;
$ratioforcrop
=
2
;
}
print
'<!-- Form to crop -->'
.
"
\n
"
;
print
'<fieldset id="redim_file">'
;
print
'<legend>'
.
$langs
->
trans
(
"Recenter"
)
.
'</legend>'
;
print
$langs
->
trans
(
"DefineNewAreaToPick"
)
.
'...<br>'
;
print
'<br><center>'
;
print
'<div style="border: 1px solid #888888; width: '
.
$widthforcrop
.
'px;">'
;
print
'<img src="'
.
DOL_URL_ROOT
.
'/viewimage.php?modulepart=product&entity='
.
$object
->
entity
.
'&file='
.
$original_file
.
'" alt="" id="cropbox" width="'
.
$widthforcrop
.
'px"/>'
;
print
'</div>'
;
print
'</center><br>'
;
print
'<form action="'
.
$_SERVER
[
"PHP_SELF"
]
.
'?id='
.
$id
.
'" method="post" onsubmit="return checkCoords();">
<div class="jc_coords">
'
.
$langs
->
trans
(
"NewSizeAfterCropping"
)
.
':
<label>X1 <input type="text" size="4" id="x" name="x" /></label>
<label>Y1 <input type="text" size="4" id="y" name="y" /></label>
<label>X2 <input type="text" size="4" id="x2" name="x2" /></label>
<label>Y2 <input type="text" size="4" id="y2" name="y2" /></label>
<label>W <input type="text" size="4" id="w" name="w" /></label>
<label>H <input type="text" size="4" id="h" name="h" /></label>
</div>
<input type="hidden" id="file" name="file" value="'
.
urlencode
(
$original_file
)
.
'" />
<input type="hidden" id="action" name="action" value="confirm_crop" />
<input type="hidden" id="product" name="product" value="'
.
$id
.
'" />
<input type="hidden" id="refsizeforcrop" name="refsizeforcrop" value="'
.
$refsizeforcrop
.
'" />
<input type="hidden" id="ratioforcrop" name="ratioforcrop" value="'
.
$ratioforcrop
.
'" />
<input type="hidden" name="id" value="'
.
$id
.
'" />
<br><input type="submit" class="button" value="'
.
dol_escape_htmltag
(
$langs
->
trans
(
"Recenter"
))
.
'" />
</form>'
.
"
\n
"
;
print
'</fieldset>'
.
"
\n
"
;
print
'<br>'
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment