Inserting image links into correct places based on section # and img file #

Hello, I’ve already spent hours on this and got quite stuck.

I’m using airtable + make.com
airtable cell 1 contains a list of image links:

1._S3758502c-4d40-a8b8-d4ed1ae24f2.png
2._b5eeb3f1-9ac4-ad75-0fa73fbbccd8.png
2._34a41a6c-e782-966b-e24fc551da5b.png
3._caba3987-45db-b709-b58f2572795a.png
4._eaf600aa-47af-4db7-b560-ee2a9148.png
5._1ebfd8ab-93c4-460e-b7fa-f7d6fa00.png
5._e1c459ca-58d7-4cea-f18fb2c5a0d6.png
5._edf93dbf-46e2-a8d3-3f8f5ea3d394.png

cell 2 contains a full post in markdown:

## 1. SubHeading
>>>
There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which
<<<<

## 2. SubHeading
>>>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer 
<<<<

## 3. SubHeading
>>>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
<<<<

##  4. SubHeading
>>>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

<<<<

## 5. SubHeading
>>>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

I am trying to insert the correct images into the correct locations, there can be multiple images below each heading, after combining the data the end result needs to look like this:

1. SubHeading

1._S3758502c-aba1-4d40-a8b8-d4ed1a1e24f2.png
There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which

2. SubHeading

2._b5eeb3f1-9ac4-4f68-ad75-0fa73fbbccd8.png
2._34a41a6c-e782-4a3a-966b-e24fc551da5b.png
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer

3. SubHeading

3._caba3987-45db-4f73-b709-b58f2572795a.png
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s

4. SubHeading

4._eaf600aa-47af-4db7-b560-ee2ab66b9148.png
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s

5. SubHeading

5._1ebfd8ab-93c4-460e-b7fa-f7d647dcfa00.png
5._e1c459ca-58d7-4cea-aa82-f18fb2c5a0d6.png
5._edf93dbf-4dda-46e2-a8d3-3f8f5ea3d394.png
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s

Progress so far:

module 1:
retrieves the airtable record

module 2:
iterates over the post splitting into sections
{{split(42.Full post Test; “<<<<”)}}

module 3:
I then use a text parser to extract the heading number
##\s*(\d+)

module 4:
Set multiple variables with heading number and post section content

module 5:
aggregates the previous module responose into an array

module 6:
second iterator splits the image list by new lines
{{split(42.Image list; newline)}}

module 7:
second text parser which extracts the image file number
^(\d+)._

module 8:
set multiple variables with img_nr and img_value

module 9:
aggregates the previous module into an array

…and this is where I get stuck, a rough idea I have of what to do next:

  1. Match the IMTKEY from Array Aggregator 2 with the heading_number from Array Aggregator
  2. Replace the placeholder >>> in the post_section with the corresponding images.
  3. Construct the final output with images inserted.




Am I on the right track? How would you proceed? Perhaps I’m missing something and it’s not even necessary to set variables for example?

Thank you in advanced for any kind of input!

Welcome to the Make community!

You will need approximately 5 modules:

Output

samliewrequest private consultation

Join the unofficial Make Discord server to chat with other makers!

2 Likes

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

View Module Export Code

JSON

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 5,
                    "module": "util:ComposeTransformer",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "value": "1._S3758502c-4d40-a8b8-d4ed1ae24f2.png\n2._b5eeb3f1-9ac4-ad75-0fa73fbbccd8.png\n2._34a41a6c-e782-966b-e24fc551da5b.png\n3._caba3987-45db-b709-b58f2572795a.png\n4._eaf600aa-47af-4db7-b560-ee2a9148.png\n5._1ebfd8ab-93c4-460e-b7fa-f7d6fa00.png\n5._e1c459ca-58d7-4cea-f18fb2c5a0d6.png\n5._edf93dbf-46e2-a8d3-3f8f5ea3d394.png"
                    },
                    "metadata": {
                        "designer": {
                            "x": -722,
                            "y": -319
                        },
                        "restore": {},
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ]
                    }
                },
                {
                    "id": 9,
                    "module": "builtin:BasicFeeder",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "array": "{{split(5.value; newline)}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": -477,
                            "y": -318
                        },
                        "restore": {
                            "expect": {
                                "array": {
                                    "mode": "edit"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "array",
                                "type": "array",
                                "label": "Array",
                                "mode": "edit",
                                "spec": []
                            }
                        ]
                    }
                },
                {
                    "id": 10,
                    "module": "util:TextAggregator",
                    "version": 1,
                    "parameters": {
                        "rowSeparator": "\n",
                        "feeder": 9
                    },
                    "mapper": {
                        "value": "{{9.value}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": -235,
                            "y": -319
                        },
                        "restore": {
                            "parameters": {
                                "rowSeparator": {
                                    "label": "New row"
                                }
                            },
                            "extra": {
                                "feeder": {
                                    "label": "Iterator [9]"
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "rowSeparator",
                                "type": "select",
                                "label": "Row separator",
                                "validate": {
                                    "enum": [
                                        "\n",
                                        "\t",
                                        "other"
                                    ]
                                }
                            }
                        ],
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ],
                        "advanced": true
                    },
                    "flags": {
                        "groupBy": "{{first(split(9.value; \".\"))}}"
                    }
                },
                {
                    "id": 11,
                    "module": "builtin:BasicAggregator",
                    "version": 1,
                    "parameters": {
                        "feeder": 10
                    },
                    "mapper": {
                        "__IMTKEY__": "{{10.`__IMTKEY__`}}",
                        "text": "{{10.text}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 11,
                            "y": -316
                        },
                        "restore": {
                            "extra": {
                                "feeder": {
                                    "label": "Tools - Text aggregator [10]"
                                },
                                "target": {
                                    "label": "Custom"
                                }
                            }
                        }
                    }
                },
                {
                    "id": 6,
                    "module": "util:ComposeTransformer",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "value": "## 1. SubHeading\nThere are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which\n\n## 2. SubHeading\nLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer \n\n## 3. SubHeading\nLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s\n\n##  4. SubHeading\nLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s\n\n## 5. SubHeading\nLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"
                    },
                    "metadata": {
                        "designer": {
                            "x": 255,
                            "y": -317
                        },
                        "restore": {},
                        "expect": [
                            {
                                "name": "value",
                                "label": "Text",
                                "type": "text",
                                "multiline": true
                            }
                        ]
                    }
                },
                {
                    "id": 7,
                    "module": "builtin:BasicFeeder",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "array": "{{split(6.value; newline + newline)}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 498,
                            "y": -319
                        },
                        "restore": {
                            "expect": {
                                "array": {
                                    "mode": "edit"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "array",
                                "type": "array",
                                "spec": [],
                                "label": "Array",
                                "editable": true,
                                "mode": "edit"
                            }
                        ]
                    }
                },
                {
                    "id": 8,
                    "module": "util:TextAggregator",
                    "version": 1,
                    "parameters": {
                        "rowSeparator": "\n",
                        "feeder": 7
                    },
                    "mapper": {
                        "value": "{{replace(7.value; \"/(?<=#.+)\\n/\"; newline + 11.array[7.`__IMTINDEX__`].text + newline)}}{{newline}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 741,
                            "y": -318,
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {
                            "parameters": {
                                "rowSeparator": {
                                    "label": "New row"
                                }
                            },
                            "extra": {
                                "feeder": {
                                    "label": "Iterator [7]"
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "rowSeparator",
                                "type": "select",
                                "label": "Row separator",
                                "validate": {
                                    "enum": [
                                        "\n",
                                        "\t",
                                        "other"
                                    ]
                                }
                            }
                        ],
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ],
                        "advanced": true
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}
2 Likes

You are a true life-saver! This worked after remapping bundle order position :heart:
Screenshot 2024-05-23 at 14.48.13

1 Like

No problem, glad I could help!

1. If you have a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

General

Help Center Basics

Articles & Videos

samliewrequest private consultation

Don’t forget to join the unofficial Make Discord server to chat with other makers!

3 Likes