How can I link a single uploaded image to multiple records

Options

The scenario is as follows:

  1. I have a field in a table for status
  2. Status can only have 2 values, active and inactive
  3. I have uploaded 2 icons to public files, one for active and the other for inactive

How can I store the 'inactive' image against each record that is inactive?

Alternatively, when creating an endpoint returning the record with a status, how do I attach the 'inactive' image with an inactive status?

Essentially the question is, how do I use a single image against multiple records?

Best Answer

  • Cameron B
    Cameron B Member, Administrator

    ADMIN

    Answer ✓
    Options

    Hey there - sounds like this particular issue could be solved with an addon as the best method.

    What I would do:

    1) I would create a new table of images . They would have the enums of active or inactive as a column, and another column for the actual image itself. I'd add two rows, one for inactive and one for active.

    2) I'd create an addon that would search for this value, provided an enum value.

    3) Then, in my query where I'm returning my data, in the output tab, I would add the addon we created in the previous step, ensuring that the data's active or inactive field is being supplied as the input for the addon.

    Let me know if this aligns with what you're trying to accomplish!

Answers

  • Finbarr
    Finbarr Member
    Options

    Thank you Cameron.

    I thought there would be a way to refer to an image by its URL but your approach will work perfectly.

    Thank you.