Opened 10 years ago
Closed 10 years ago
#7409 closed enhancement (fixed)
Action request: cover image deleted
| Reported by: | jdgrimes | Owned by: | boonebgorges |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.8 |
| Component: | Core | Version: | 2.5.0 |
| Severity: | normal | Keywords: | good-first-bug has-patch |
| Cc: |
Description
There is an action ("{$object_data['component']}_cover_image_uploaded") that fires in bp_attachments_cover_image_ajax_upload(), and there should be a complementary one in bp_attachments_cover_image_ajax_delete(). Otherwise it is possible to do something when a cover image is uploaded, but not to reverse any of the effects when the cover image is deleted.
Attachments (2)
Change History (8)
#1
@
10 years ago
- Keywords good-first-bug needs-patch added
- Milestone Awaiting Review → 2.8
- Version → 2.5.0
#2
@
10 years ago
- Keywords has-patch added; needs-patch removed
I've uploaded 7409-2.diff as a first pass.
#3
@
10 years ago
- Keywords 2nd-opinion added
As an idea.
What about the difference in approaches:
do_action( "{$component}_cover_image_deleted", (int) $cover_image_data['item_id'] );
vs
do_action( "bp_component_cover_image_deleted", (int) $cover_image_data['item_id'], $component );
Personally I would go with the second one, as it will allow much easier targeting in a hook of all components that have cover image deleted.
Currently in a patch by @jdgrimes we need to get the list of components, and among them those that are using cover images to be able to target ANY covers deletion. That's a lot of extra work where it's easy to make a mistake.
#4
follow-up:
↓ 5
@
10 years ago
- Keywords 2nd-opinion removed
I agree with @slaFFik that we should generally avoid dynamic action/filter names, as they're harder to read and harder to document. The one time they're really advantageous is when a hook might be fired very, very frequently; in this case, it's better for performance to avoid invoking extra callbacks. The case of deleting a cover image isn't one of these instances.
That being said, if we already have a dynamic hook name for updating, we should probably do the same thing for deletion, just for the sake of consistency.
#5
in reply to: ↑ 4
@
10 years ago
Replying to boonebgorges:
That being said, if we already have a dynamic hook name for updating, we should probably do the same thing for deletion, just for the sake of consistency.
Yes, I was just following the pattern of the "{$object_data['component']}_cover_image_uploaded" action.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Adds the deleted action