Skip to content
Extraits de code Groupes Projets
Valider d6b24cc4 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

Merge pull request #9471 from piwik/customlogo_improvements

Better error handling for custom logo upload
parents a1315849 5160e1ff
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -196,18 +196,22 @@ class CustomLogo
list($width, $height) = getimagesize($file);
switch ($_FILES[$uploadFieldName]['type']) {
case 'image/jpeg':
$image = imagecreatefromjpeg($file);
$image = @imagecreatefromjpeg($file);
break;
case 'image/png':
$image = imagecreatefrompng($file);
$image = @imagecreatefrompng($file);
break;
case 'image/gif':
$image = imagecreatefromgif ($file);
$image = @imagecreatefromgif ($file);
break;
default:
return false;
}
if (!is_resource($image)) {
return false;
}
$targetWidth = round($width * $targetHeight / $height);
$newImage = imagecreatetruecolor($targetWidth, $targetHeight);
......
......@@ -113,6 +113,7 @@ $(document).ready(function () {
$("#logoUploadForm").submit(function (data) {
var submittingForm = $(this);
$('.uploaderror').fadeOut();
var frameName = "upload" + (new Date()).getTime();
var uploadFrame = $("<iframe name=\"" + frameName + "\" />");
uploadFrame.css("display", "none");
......@@ -123,6 +124,10 @@ $(document).ready(function () {
var frameContent = $(uploadFrame.contents()).find('body').html();
frameContent = $.trim(frameContent);
if ('0' === frameContent) {
$('.uploaderror').show();
}
if ('1' === frameContent || '0' === frameContent) {
uploadFrame.remove();
}
......
......@@ -49,6 +49,7 @@
"JSTrackingIntro5": "If you want to do more than track page views, please check out the %1$sPiwik Javascript Tracking documentation%2$s for the list of available functions. Using these functions you can track goals, custom variables, ecommerce orders, abandoned carts and more.",
"LogoNotWriteableInstruction": "To use your custom logo instead of the default Piwik logo, give write permission to this directory: %1$s Piwik needs write access for your logos stored in the files %2$s.",
"FileUploadDisabled": "Uploading files is not enabled in your PHP configuration. To upload your custom logo please set %s in php.ini and restart your webserver.",
"LogoUploadFailed": "The uploaded file couldn't be processed. Please check if the file has a valid format.",
"LogoUpload": "Select a Logo to upload",
"FaviconUpload": "Select a Favicon to upload",
"LogoUploadHelp": "Please upload a file in %s formats with a minimum height of %s pixels.",
......
......@@ -204,6 +204,9 @@
<input type="hidden" name="token_auth" value="{{ token_auth }}"/>
{% if logosWriteable %}
<div class="alert alert-warning uploaderror" style="display:none;">
{{ 'CoreAdminHome_LogoUploadFailed'|translate }}
</div>
<div class="form-group">
<label for="customLogo">{{ 'CoreAdminHome_LogoUpload'|translate }}</label>
<div class="form-help">{{ 'CoreAdminHome_LogoUploadHelp'|translate("JPG / PNG / GIF", 110) }}</div>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter