diff --git a/vasl_templates/webapp/snippets.py b/vasl_templates/webapp/snippets.py index 6c933bb..ae94484 100644 --- a/vasl_templates/webapp/snippets.py +++ b/vasl_templates/webapp/snippets.py @@ -7,6 +7,7 @@ import zipfile import io import base64 import threading +import urllib.request from flask import request, jsonify, send_file, abort from PIL import Image @@ -178,8 +179,11 @@ def get_flag( nat ): if globvars.template_pack: fname = globvars.template_pack.get( "nationalities", {} ).get( nat, {} ).get( "flag" ) if fname: - with open( fname, "rb" ) as fp: - return _get_small_image( fp, key, height ) + if fname.startswith( ("http://","https://") ): + fp = urllib.request.urlopen( fname ) + else: + fp = open( fname, "rb" ) + return _get_small_image( fp, key, height ) # serve the standard flag fname = os.path.join( "static/images/flags/", nat+".png" ) diff --git a/vasl_templates/webapp/static/utils.js b/vasl_templates/webapp/static/utils.js index 3d32a64..aa8991b 100644 --- a/vasl_templates/webapp/static/utils.js +++ b/vasl_templates/webapp/static/utils.js @@ -34,6 +34,9 @@ function get_player_colors_for_element( $elem ) } function make_player_flag_url( nat, for_snippet ) { + var flag = gTemplatePack.nationalities[nat].flag ; + if ( flag ) + return flag ; // nb: custom flag, just use that if ( for_snippet && gUserSettings["scenario-images-source"] == SCENARIO_IMAGES_SOURCE_INTERNET ) return gAppConfig.ONLINE_IMAGES_URL_BASE + "/flags/" + nat + ".png" ; else