Is there a way to collapse a group when an element can't be loaded?

I have a repeating group that is pulling data and images from the mysql plugin. Sometimes I get a general warning in the preview debugger which says “The image could not be loaded”. The reason is because the URL doesn’t have an image associated with it yet. I’m wondering if I can collapse or hide the row when this is the case so it doesn’t look so horrible to see a bunch of rows with empty images.

Condition: Is image empty? Show contents yes/no.

Apply that to parent group inside the RG.

Hey @GH5T - thanks for the super speedy reply! The image field is not empty. It has a URL but the URL doesn’t yet point to an actual image so if I were to try to open it in a web browser I would get a browser notification that there’s no style information. Basically I haven’t uploaded the image yet.

I’m not technical enough to know how Bubble knows that the image could not be loaded. I wonder if I can somehow get the information and then use a conditional? :thinking:

that could actually require a little more action. I’m bout to head out for the night, i’ll come back and let you know what I think could work.

1 Like

How are you handling data? Can you add another data set that is like “isFullyUploaded” or some sort of check for when you initially upload the image?

The way I handle it now: I have sensor data that uploads immediately and images that upload only every once in a while (like when there’s enough internet). The sensor data goes to aws rds and the images go to aws s3 bucket. Since internet speed is a challenge for my application, I try to reduce the amount of uploading/updating I’m doing on the edge device so right now I just have a trigger in mysql which fills in the image column with the URL string pattern that is associated with the correct sensor data row.

Adding a check idea: I suppose I could have a lambda function trigger when an image is uploaded to S3. That trigger could then update a column in mysql to confirm the image is uploaded. Not sure what the cost efficiency of that is.

Another idea is to have a condition on the group in the repeating group which checks an API. The API then checks for errors and, based on the response, I can then hide the group which collapses the repeating group row. Something like the below in Python using Flask . I’m still not sure about the cost efficiency though.

import requests

def check_url_for_errors(url):
    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an exception for 4xx and 5xx status codes
        print(f"The URL '{url}' is accessible without errors.")
    except requests.exceptions.RequestException as e:
        print(f"Error accessing the URL '{url}': {e}")

url_to_check = "https://www.example.com"  # Replace with the URL you want to check
check_url_for_errors(url_to_check)

Adding another value shouldn’t cost much. Regardless, adding a flag for checking validity is probably your best bet.