Featured image #342
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!342
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "featured-image"
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?
adds featured image at peer_reviewed_article.
Looks good, very comfortable to review with all these nice and small commits :-)
I left some small remarks inline.
Furthermore:
handleImageUploadcall currently).handleImageUploadcould be generalized to ahandleFileUploads($_FILES)that just processes all fields in$form->file_fields, rather than just one, so callers need less checking and less hardcoding of the form structure in the processing code.I think this might need to be scoped to the containing
formtag, in case multiple forms with the same name are present (not possible now, but can happen later). I think something like this would work:Why is this needed?
Does this produce a meaningful URL, or a data url? If the latter, there's no real point in saving it into the shadow field in
updateSrc, I think?Why not merge
toggleandupdateSrcinto one function?I was also thinking hat if you use the value of the shadow field here, rather than the preview src, we could remove the preview handling on the PHP side, but that would prevent the preview from being resized (which might not be terrible, of course).
@ -0,0 +73,4 @@* Take an uploaded image file, move it into the data* directory and return the corresponding HyphaImage* instance.*You added translations for this, but are not using them here.
Did you intentionally remove this check?
@ -482,6 +503,13 @@}Maybe use
array_key_existsrather thanemptyin these two lines, for consistency with the lines below?@ -481,2 +495,3 @@// create form$form = $this->createEditForm($request->getPostData());$form = $this->createEditForm($formData);Why add the
ROOT_PATHhere? That only hurts portability (moving the hypha installation)? Leaving it out also prevents having to remove it again when inserting data into the form values later? Also, when using this filename, you'd normally pass it to theHyphaFileconstructor, which also needs it without theROOT_PATHprepended.@ -1196,2 +1220,4 @@</div></div><div class="section" style="padding:5px; margin-bottom:5px; position:relative;"><div class="input-wrapper field_type_editor field_name_[[field-name-text]]">This would probably be more readable as an
ifstatement.@ -94,3 +94,3 @@"error-loading-html" => "setNodeHTML: error when loading HTML","too-big-file" => "Error: file must be less than ","too-big-file" => "Error: file must be less than [[upload-max-filesize]]","invalid-image-file" => "Invalid image file, must be a valid image less than ",You changed this translation, but not the place it is called.
This uses
_while variables elsewhere (includingtoo-big-fileabove) uses-. Better also use-here (no need to strictly match the php.ini variable here, I think).@ -94,3 +94,3 @@"error-loading-html" => "setNodeHTML: error when loading HTML","too-big-file" => "Error: file must be less than ","too-big-file" => "Error: file must be less than [[upload-max-filesize]]","invalid-image-file" => "Invalid image file, must be a valid image less than ",good catch! fixed
fixed
@ -0,0 +73,4 @@* Take an uploaded image file, move it into the data* directory and return the corresponding HyphaImage* instance.*fixed
@ -0,0 +73,4 @@* Take an uploaded image file, move it into the data* directory and return the corresponding HyphaImage* instance.*Nope, placed it back
@ -482,6 +503,13 @@}fixed
I ran into the problem that the label was still working on the hidden input. I just fixed this issue by disabling the input. :-)
True, i just need to put something there, so we can detect if the image remained the same, got replaced or removed.
This would not work because the shadow field value does not contain the correct path.
What does "working on" mean for a label anyway? The label is still shown, and associated with the same input, which is hidden. Doesn't sound (semantically) incorrect? Does this confuse the browser somehow? You could argue that the label should now associate with the preview or the remove button, but I'm not so sure this is possible or useful?
But you do not need to detect "replaced" using the hidden field, I think, since that is detected when a new file upload has happened in the file input. Removed does need to be detected, but that can just empty out the field?
If we add a library-browser type thing later (where you can select existing images), you can just put the already known public URL of these images in the input field as well.
Yeah, I guess. Still, merging
toggleandupdateSrcseems reasonable?fixed
fixed
merged
@ -481,2 +495,3 @@// create form$form = $this->createEditForm($request->getPostData());$form = $this->createEditForm($formData);fixed
@ -1196,2 +1220,4 @@</div></div><div class="section" style="padding:5px; margin-bottom:5px; position:relative;"><div class="input-wrapper field_type_editor field_name_[[field-name-text]]">If the
ROOT_PATHis not saved, this whole part can be removed.It confusing for the user if a file upload dialog is triggered while that input field is hidden. I've added a comment. :-)
Processed all comments. @matthijskooijman please review the changes.
agreed
agreed
Let's fix the festival module after merging this PR.
Ah, I didn't realize that clicking the label triggers the input field, good point.
I left one more question, and wondered: Should the featured image be shown along with the excerpt (for logged in users)?
Why does this attribute exist?
true, not needed. fixed
Good idea! I'll implement it.
@laurensmartina, I added one small simplification, see the added fixup commit. If that looks good to you, I'll squash and merge this tomorrow.
Rebased on top of master, merging next.