PHP HTML Substitution?

In my blog DevPack, I am using substitution codes that can be inserted into Text or Typography components and the Devpack will substitute those codes with the metadata values from a displayed post.

The codes (at the moment; there will be more) are:

  • {DATETIME}
  • {CATEGORY}
  • {TITLE}
  • {SUMMARY}

The problem comes with an image as there is now way to specify {IMAGE} in an Image component and override it with the image from the metadata.

So I am searching for files/image-square.png and replacing that with the image link from the metadata. Whilst this works well, it is obviously risky going forward if that default filename was to change?

I was wondering whether there was a way to manually input the the image link into the Image component to avoid this, so that {IMAGE} could be used?

Conversely, do I need to be worried by this?

Just an update on this, I did caught out! If you have a different web page at the root level, the default image files are name with the filename added to the front. So if you have a webpage called blogging.php, the associated default image file is named blogging_files/image-square.png.

Anyway, with the assistance of ChatGPT, I now just check for image-square.png with any parent folder and that handles both cases. :slightly_smiling_face:

1 Like