Skip to content

Commit

Permalink
Merge pull request #3657 from klikstermkd/3656-default-logo-image-break
Browse files Browse the repository at this point in the history
Fix broken default logo image
  • Loading branch information
amercader committed Jul 18, 2017
2 parents fac76d6 + 79f6fbf commit 8d08d3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ckan/logic/action/update.py
Expand Up @@ -7,6 +7,7 @@
import time
import json
import mimetypes
import os

from ckan.common import config
import paste.deploy.converters as converters
Expand Down Expand Up @@ -1273,8 +1274,11 @@ def config_option_update(context, data_dict):
for key, value in data.iteritems():

# Set full Logo url
if key =='ckan.site_logo' and value and not value.startswith('http'):
value = h.url_for_static('uploads/admin/{0}'.format(value))
if key == 'ckan.site_logo' and value and not value.startswith('http')\
and not value.startswith('/'):
image_path = 'uploads/admin/'

value = h.url_for_static('{0}{1}'.format(image_path, value))

# Save value in database
model.set_system_info(key, value)
Expand Down
5 changes: 5 additions & 0 deletions ckan/public/base/javascript/modules/image-upload.js
Expand Up @@ -129,6 +129,11 @@ this.ckan.module('image-upload', function($) {
* Returns String.
*/
_fileNameFromUpload: function(url) {
// If it's a local CKAN image return the entire URL.
if (/^\/base\/images/.test(url)) {
return url;
}

// remove fragment (#)
url = url.substring(0, (url.indexOf("#") === -1) ? url.length : url.indexOf("#"));
// remove query string
Expand Down

0 comments on commit 8d08d3a

Please sign in to comment.