def image_url(self): if is_devserver(): subpath = ("img" + os.sep + "pets" + os.sep + self.species.canon_name + os.sep + self.coat_name + ".png") image_path = (os.path.join(go_up_path(4, (__file__)), "static", subpath)) if os.path.isfile(image_path): return url_for("static", filename=subpath) + "?v=" + str(get_static_version_id()) return (app.config['IMAGE_BUCKET_ROOT'] + "/pets/" + self.species.canon_name + "/" + self.coat_name + ".png?v=" + str(get_static_version_id()))
def random_image_helper(folder): name = random.choice(os.listdir(folder)) name_path = folder + name subpath = name_path[name_path.rfind("static" + os.sep) + 7:] if os.path.isdir(name_path): return random_image_helper(name_path + os.sep) elif name.endswith(".png") or name.endswith(".jpg"): return (url_for('static', filename=subpath) + '?v=' + str(get_static_version_id())) else: return random_image_helper(folder)
def inject_version_id(): return dict(version_id=get_static_version_id())
def include_static(file_path): return url_for('static', filename=file_path) + '?v=' + str(get_static_version_id())