File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -34,3 +34,26 @@ def get_site_statistics():
3434
3535def showcase_get_wysiwyg_editor ():
3636 return tk .config .get ('ckanext.showcase.editor' , '' )
37+
38+
39+ def get_value_from_showcase_extras (extras , key ):
40+ value = ''
41+ for item in extras :
42+ if item .get ('key' ) == key :
43+ value = item .get ('value' )
44+ return value
45+
46+ # look for a thumbnail image for image found at path image_url and returns the thumbnail url if it exists
47+ # if no thumbnail exists, the original image_fp is returned
48+ def get_thumbnail ( image_name ):
49+
50+ # convert image url to file path
51+ #image_fp = tk.config.get("ckan.storage_path") + '/storage' + image_name
52+
53+ # convert image_fp to thumb_fp by adding -thumbnail before the file extension
54+ thumb_name = "{0}-{2}.{1}" .format (* image_name .rsplit ('.' , 1 ) + ['thumbnail' ])
55+
56+ if exists ( tk .config .get ("ckan.storage_path" ) + '/storage/uploads/showcase/' + thumb_name ):
57+ return thumb_name
58+ else :
59+ return image_name
You can’t perform that action at this time.
0 commit comments