2

I'm doing this to display multiple images with dash but it clearly isn't working as it only displays one image.

for i in images:
    app.layout = html.Div([
        html.Div([
            html.A([
                html.Img(
                    src=app.get_asset_url(i),
                    style={
                        'height' : '40%',
                        'width' : '40%',
                        'float' : 'left',
                        'position' : 'relative',
                        'padding-top' : 0,
                        'padding-right' : 0
                    }
                )
            ], href='https://www.google.com'),
        ])
    ]) 

What could be the easiest way to do this. Take into account these are images not plots.

1 Answer 1

4

I managed to make it work like this

def generate_thumbnail(image):
    return html.Div([
        html.A([
            html.Img(
                src = app.get_asset_url(i),
                style = {
                    'height': '40%',
                    'width': '40%',
                    'float': 'left',
                    'position': 'relative',
                    'padding-top': 0,
                    'padding-right': 0
                }
            )
        ], href = 'https://www.google.com'),
    ])

images_div = []
for i in images:
    images_div.append(generate_thumbnail(i))
app.layout = html.Div(images_div)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.