I am running into 2 related problems at the moment in my theme component,
- Check if the post starts with an image, I am currently getting the post content using document.querySelector(“.topic-post:first-child .cooked”) but if the post starts with an image, I get the image name and size before the start of the text, so I want a way to remove this.
- If the post is only an image, with no text, I want a way to get that image (or a link to the image).
The purpose of the theme component is to have a share button that generates an image which users can download to share that contains the post title and the first few lines of the post. If the post has no text, instead have the image in the post inside of the generated image. I currently have the text parts figured out, but there are two cases where issues crop up, one, where the image is near the start of the post so the text I extract is “{imagename}1080x2100 14 KB[rest of the text]” or where the only thing in the post is an image and the text extracted is “{imagename}1080x2100 14 KB”
And what I want is either to have just text, or just an image.