Opened 10 years ago
Last modified 2 months ago
#33963 new enhancement
New function: `upload_url()`
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Upload | Keywords: | reporter-feedback has-patch |
| Focuses: | Cc: |
Description
Retrieve the url to the uploads directory.
Attachments (2)
Change History (10)
#2
follow-up:
↓ 4
@
10 years ago
- Component changed from General to Upload
- Keywords reporter-feedback added
- Type changed from defect (bug) to enhancement
Thanks for the patch, Sebastian.
What's the use case for needing the URL for the uploads directory?
#3
@
10 years ago
- Keywords needs-refresh added
@sebastian.pisula, minor nitpick: the second part, you can just set it to $upload_dir['url'] instead of adding the string
#4
in reply to:
↑ 2
@
10 years ago
What's the use case for needing the URL for the uploads directory?
Perhaps we could use this function at various places in core where $upload_dir['url'] is accessed directly?
$url = upload_url() isn't much of an improvement over $upload_dir = wp_upload_dir(); $url = $upload_dir['url'] though.
This ticket was mentioned in Slack in #core by sebastian.pisula. View the logs.
10 years ago
#7
@
7 years ago
@sebastianpisula is this still of interest to you? If so, the patch needs refreshing.
This ticket was mentioned in PR #9865 on WordPress/wordpress-develop by @abcd95.
2 months ago
#8
- Keywords needs-refresh removed
Trac ticket: https://core.trac.wordpress.org/ticket/33963
Adds a new upload_url() helper function that returns the uploads directory URL.
- Defaults to returning the current time-based uploads URL (
wp_upload_dir()['url']). - Optionally returns the base uploads URL without the subdirectory.
- Returns an empty string on error.
- Provides clearer naming and documentation compared to direct
wp_upload_dir()access.
#33964 was marked as a duplicate.