SpinaCMS / spina-blog

Blog engine for Spina CMS
MIT License
11 stars 25 forks source link

Captions on images embedded in post content uneditable (admin) and not appearing (frontend). #27

Open aseroff opened 2 years ago

aseroff commented 2 years ago

On versions 0.3.0 and at master@d813dae, I'm experiencing issues with images included in a post's content.

The first problem is that while composing a post in admin, for all embedded images after the first, it becomes impossible to click on the Alt Text placeholder text to set a caption for the images. I have noted that in a rich text field of a page in the Spina (non-blog) side of things, this is not an issue - a floating text field appears for all images that allows editing of the alt text value.

Next, for all images (including the first), the caption text does not appear as part of the rendering of @post.content.html_safe. While inspecting in browser, I can see

<figure data-trix-attachment="{&quot;content&quot;:&quot;<span class=\&quot;trix-attachment-spina-image\&quot; data-label=\&quot;CAPTION\&quot;>\n<img src=\&quot;http://localhost:3000/rails/active_storage/representations/...\&quot; alt=\&quot;CAPTION\&quot;>\n    </span>&quot;,&quot;contentType&quot;:&quot;Spina::Image&quot;}" data-trix-content-type="Spina::Image" class="attachment attachment--content">
  <span class="trix-attachment-spina-image" data-label="CAPTION">
      <img src="http://localhost:3000/rails/active_storage/representations/..." alt="CAPTION">
  </span>
  <figcaption class="attachment__caption"></figcaption>
</figure>

As you can see, the figcaption is empty, despite the alt text value ("CAPTION") being propagated throughout the figure. It seems odd for it not to be placed as the value for figcaption. This behavior is identical between spina_blog's posts and spina's pages, which leads me to believe that it may be a desired behavior that the text is alt text only and not meant to be a caption. If this is true, I believe this is a feature request. I'm in the process of replacing a wordpress with a spina implementation, and the inability for a content manager to be able to manipulate image placement and caption in a post is the only showstopper I've run into.

I've acquainted myself with an issue over at the Spina framework repo, where alt tags were extended into the trix implementation, perhaps making them a caption as well can be considered? Over in that thread I also see a gif for image placement, which would be welcome as well, however I don't experience that behavior.