implement caption and meta-information for images #119 #344
No reviewers
Labels
No labels
Component: User interface
Component: Wymeditor
Help wanted
Level: Difficult
Level: Easy
Level: Moderate
Pagetype: Festival
Pagetype: Mailinglist
Pagetype: Peer reviewed article
Pagetype: Text
Privacy GDPR AVG
status: has conflicts
Status: Needs changes
Status: Needs discussion
Status: Needs review
Status: Ready to merge
Status: Waiting for response
Type: Bug
Type: Enhancement
Type: Question
Usecase: De Stadsbron
Usecase: Koppelting
Usecase: MeetjeStad
Value: Coders
Value: Security
Value: Users
Value: Visitors
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
harmen/hypha!344
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "hypha-119"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #119
I think I might be misunderstanding how all of this fits together, so I asked some questions inline. Maybe we should look at this together this afternoon.
I would rename these functions to more descriptive names, maybe
add_captions_to_all_imagesandadd_caption_to_image?Doesn't this need a
<figure>tag as well to group the caption with the image? https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figcaptionThis seems weird: You enter an attribution, which is then saved as a "long description", and displayed as a caption, which seem three distinct things that I think we should not mix here? Maybe this is also something that @giplt could comment on?
IIUC this processes an "attribution" attribute returned from the image upload handler, but I see no changes in the upload handler?
@ -54,0 +81,4 @@wym.registerModification();} else {wym.insertImage(imgAttrs);}Why is this submitHandler completely new? I would think that adding attribution would only need to add one attribute to an existing handler. Is there maybe a hidden extra change here?
True! A next feature will be that the upload will return "attribution". This code is unaware of the state of the upload and already prepared.
fixed!
I've implemented it like it was requested by @tammoterhark, I think he had a clear vision about this.
Ah, I didn't know! fixed
@ -54,0 +81,4 @@wym.registerModification();} else {wym.insertImage(imgAttrs);}No extra change, AFAIK the submitHandler needs to be overwritten in order to add a new attribute. Of course I'm open for suggestions.
I left a bunch of inline comments which I also fixed in two fixup commits that I'll push in a minute.
I did find some other problems that are still unfixed right now and might need us to rethink our approach. In particular:
<figure>tag is a block-level tag, while<img>is inline, so adding thefigurecreates invalid HTML, causing at least my Firefox to drop the<figure>, it seems..leftclass to make the image floating and have text wrap around it, but this breaks when wrapped inside<figure>.Not sure if there is an easy fix for these, so maybe we should be storing
<figure>tags after all?I think the xpath can be simplified to:
This adds an empty
figcaptionwhen no title exists, which looks weird. Also, I think that it would make sense to put the attribution inside the caption, so they can be styled together if needed, and then put the title in a span with a class so it can also be styled separately.This can be shorted using the
wrapmethod. Documentation was missing, so I submitted https://github.com/scotteh/php-dom-wrapper/pull/31.I think it's better to use
$doc->createElement()instead of this, to get an element that is associated with the right document directly, which allows making modifications to it directly (I had problems with e.g.addClass()on directly-createdDOMWrap\Elementinstances, even after inserting them into a document, possibly this results in a clone being made into the right document).Another advantage of using
createElementis that you do not needlessly expose theDOMWrap\Elementclass name (you just automatically get the right class based on the document you're using).I'm still unsure what "cc" means here. If it's intended to be "Creative Commons", then this might actualy be misleading, since just "CC" is not specific enough. I think we should just use "e.g." here, since it's intended as a suggestion? Or actually, maybe "license: author (date)" was the intention and is actually helpful, since it suggests to people that a license is actually needed. Let's try that and see what feedback we get.
One additional thing I found is that you now explicitly exclude any HTML inside wymeditor, which I had expected to be not needed since this should live as text (rather than HTML) inside a textarea. However, I found that we actually changed this to HTML in
b6f630ee8bto actually allow the global dewikify to process this. However, this results in actual (non-escaped) HTML to end up in the<textarea>tag, which is not technically correct HTML (though it seems browsers will allow it in practice).Also note that this editor starts out as an
<editor>tag and is later transformed into atextareatag by this bit of code. This makes the current code in this PR fragile: If it would happen to run before rather than after this transformation, the.wymeditorclass would not exist yet and it would add captions inside the wymeditor too.I think it might be better to just revert to storing text rather than HTML, but manually run
dewikify(and maybe other things needed) on the HTML before converting it to text and inserting it into the editor.I also wonder if we really need this
editortag at all, maybe it would be simpler and more transparent to just use<textarea class="wymeditor">instead of<editor>in the forms directly? Does not really look any less readable to me either?updated to "attribution"
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.