Two ways to attach images, each with a text caption, to the post, which is better?

To provide the feature of attaching images to posts with the ability to add a text caption for each image, as is the case when publishing a post on Facebook, I can build this functionality in two ways:

1- add a data type for posts and another data type for attachments (attachment contain a field for image and another field for the text caption of the image) then link those tow data types to each other, so the posts can be displayed by a RG that search for posts and inside it another RG that search for attachments related to cell’s post.

2- add just one data type for posts contains tow list fields, one list field for images and another list field for the text captions of the images, so the posts can be displayed by a RG that search for posts and inside it another RG that display the post’s list of images (by making current cell's post's images is the data source) and also display the text caption in each cell (by using some plugins inside the second RG to retrieve the right text caption).

Which of the two ways is better?

Option 1 is better, if you ask me.

Isn’t it better to stick to one data type instead of two? Maybe in terms of data volume and search speed?

Not in my opinion, no…

Maybe in terms of data volume and search speed?

Option 1 will almost certainly be better overall for performance, as you’ll only be loading the data you need, when you need it, plus it avoids any need for plugins, and avoids any problems you’ll have trying to match items in two parallel lists if a user gives the same caption for more than one image (which you won’t be able to do).

Plus it’s simpler to set up and manage.

But you can always test it to see for yourself which is better in terms of data speed and performance using your browser dev tools.

1 Like