Opened 11 years ago
Last modified 14 months ago
#33963 new enhancement
New function: `upload_url()`
| Reported by: | sebastian.pisula | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Upload | Version: | |
| Severity: | normal | Keywords: | reporter-feedback has-patch |
| Cc: | Focuses: |
Description
Retrieve the url to the uploads directory.
Attachments (2)
Change History (10)
#2
follow-up:
↓ 4
@
11 years ago
- Component General → Upload
- Keywords reporter-feedback added
- Type defect (bug) → enhancement
Thanks for the patch, Sebastian.
What's the use case for needing the URL for the uploads directory?
#3
@
11 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
@
11 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.
11 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.
14 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
#33964 was marked as a duplicate.