Merge branch 'MDL-50041-master' of git://github.com/FMCorz/moodle

This commit is contained in:
Dan Poltawski 2015-04-29 11:53:47 +01:00
commit f60ea7d7df
3 changed files with 10 additions and 5 deletions

View File

@ -966,7 +966,7 @@ function badges_process_badge_image(badge $badge, $iconfile) {
require_once($CFG->libdir. '/gdlib.php');
if (!empty($CFG->gdversion)) {
process_new_icon($badge->get_context(), 'badges', 'badgeimage', $badge->id, $iconfile);
process_new_icon($badge->get_context(), 'badges', 'badgeimage', $badge->id, $iconfile, true);
@unlink($iconfile);
// Clean up file draft area after badge image has been saved.

View File

@ -88,16 +88,20 @@ function imagecopybicubic($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $d
}
/**
* Stores optimised icon images in icon file area
* Stores optimised icon images in icon file area.
*
* Since 2.9 this function will generate an icon in the same format as the original file when possible.
* To counter that behaviour, you can use the argument $preferpng to generate a PNG icon.
*
* @param context $context
* @param string $component
* @param string filearea
* @param int $itemid
* @param string $originalfile
* @param boolean $preferpng When true, it will try to generate a PNG file regardless of the original file.
* @return mixed new unique revision number or false if not saved
*/
function process_new_icon($context, $component, $filearea, $itemid, $originalfile) {
function process_new_icon($context, $component, $filearea, $itemid, $originalfile, $preferpng = false) {
global $CFG;
if (!is_file($originalfile)) {
@ -139,7 +143,7 @@ function process_new_icon($context, $component, $filearea, $itemid, $originalfil
return false;
}
// If the user uploads a jpeg them we should process as a jpeg if possible.
if (function_exists('imagejpeg')) {
if (!$preferpng && function_exists('imagejpeg')) {
$imagefnc = 'imagejpeg';
$imageext = '.jpg';
$filters = null; // Not used.

View File

@ -41,7 +41,8 @@ information provided here is intended especially for developers.
* profile_display_badges() has been deprecated. See MDL-48935 for details.
* Added a new method add_report_nodes() to pagelib.php. If you are looking to add links to the user profile page under the heading "Reports"
then please use this function to ensure that the breadcrumb and navigation block are created properly for all user profile pages.
* process_new_icon() now does not always return a PNG file. When possible, it will try to keep the format of the original file.
Set the new argument $preferpng to true to force PNG. See MDL-46763 and MDL-50041 for details.
=== 2.8 ===