Opened 21 months ago

Closed 8 months ago

Last modified 8 months ago

#18543 closed enhancement (fixed)

Wrap imagejpeg et al to support stream wrappers

Reported by: adambackstrom Owned by:
Priority: normal Milestone: 3.5
Component: Media Version:
Severity: normal Keywords:
Cc: scribu, adambackstrom, japh@…

Description

The GD functions imagejpeg(), imagegif() and imagepng() do not support writing to PHP stream wrappers. This patch provides new wp_imagejpeg(), wp_imagegif(), and wp_imagepng() functions which wrap the GD functions, and a backend function _wp_imageany() which (if necessary) output buffers the image and writes to a stream URL.

A supporting function, wp_is_stream(), is used to identify paths that are stream URLs.

An alternative implementation of _wp_imageany() could write the image to a tmpfile and then copy the image to the stream URL.

Attachments (6)

gd-imagejpeg-wrapper-ob.2.diff (5.5 KB) - added by adambackstrom 21 months ago.
gd-imagejpeg-wrapper-ob.diff (5.5 KB) - added by adambackstrom 21 months ago.
gd-imagejpeg-wrapper-tempnam.diff (5.5 KB) - added by adambackstrom 21 months ago.
Alternate using temp file rather than output buffering (recommended by dd32)
gd-imagejpeg-wrapper-ob.3.diff (5.5 KB) - added by adambackstrom 21 months ago.
Bugfix output buffered version; always turn off ob before function ends (thanks, dd32)
wp_mkdir_p.diff (895 bytes) - added by adambackstrom 21 months ago.
Prevent wp_mkdir_p from stripping after the URL scheme
wp_mkdir_p.2.diff (895 bytes) - added by adambackstrom 21 months ago.
Prevent wp_mkdir_p from stripping // after the URL scheme

Download all attachments as: .zip

Change History (13)

  • Cc scribu added
  • Cc adambackstrom added

gd-imagejpeg-wrapper-ob.2.diff is a dupe, please ignore.

Alternate using temp file rather than output buffering (recommended by dd32)

Bugfix output buffered version; always turn off ob before function ends (thanks, dd32)

Prevent wp_mkdir_p from stripping after the URL scheme

Prevent wp_mkdir_p from stripping // after the URL scheme

  • Milestone changed from Awaiting Review to 3.5

I would really like to see this added to 3.5, to complement our focus on the media, upload, and gallery user experience.

I think this is closely related to #6821.

  • Cc japh@… added
  • Keywords has-patch added
  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [22094]

  • Keywords has-patch removed
Note: See TracTickets for help on using tickets.