Пример #1
0
def file_preview(entity_id: int) -> str:
    icon_path = get_file_path(entity_id, app.config['IMAGE_SIZE']['table'])
    size = app.config['IMAGE_SIZE']['table']
    parameter = f"loading='lazy' alt='image' width='{size}'"
    if icon_path:
        url = url_for('display_file', filename=icon_path.name, size=size)
        return f"<img src='{url}' {parameter}>"
    path = get_file_path(entity_id)
    if path and ImageProcessing.check_processed_image(path.name):
        icon_path = get_file_path(entity_id, app.config['IMAGE_SIZE']['table'])
        url = url_for('display_file', filename=icon_path.name, size=size)
        return f"<img src='{url}' {parameter}>"
    return ''
Пример #2
0
def file_preview(entity_id: int) -> str:
    icon_path = get_file_path(entity_id, app.config['IMAGE_SIZE']['table'])
    size = app.config['IMAGE_SIZE']['table']
    if icon_path:
        url = url_for('display_file', filename=icon_path.name, size=size)
        return f"<img src='{url}' loading='lazy'>" ""
    path = get_file_path(entity_id)
    if not path:
        return ''
    if ImageProcessing.check_processed_image(path.name):
        icon_path = get_file_path(entity_id, app.config['IMAGE_SIZE']['table'])
        url = url_for('display_file', filename=icon_path.name, size=size)
        return f"<img src='{url}' loading='lazy' alt='image'>"
    return ''
Пример #3
0
def display_profile_image(entity: Entity) -> str:
    if not entity.image_id:
        return ''
    path = get_file_path(entity.image_id)
    if not path:
        return ''  # pragma: no cover
    resized = None
    size = app.config['IMAGE_SIZE']['thumbnail']
    if session['settings']['image_processing'] \
            and ImageProcessing.check_processed_image(path.name):
        resized = url_for('display_file',
                          filename=get_file_path(entity.image_id, size).name,
                          size=size)
    return Markup(
        render_template('util/profile_image.html',
                        entity=entity,
                        path=path,
                        resized=resized))