Make WordPress Core

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#18543 closed enhancement (fixed)

Wrap imagejpeg et al to support stream wrappers

Reported by: adambackstrom's profile adambackstrom Owned by:
Milestone: 3.5 Priority: normal
Severity: normal Version:
Component: Media Keywords:
Focuses: Cc:

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

Download all attachments as: .zip

Change History (13)

#1 @scribu
13 years ago

  • Cc scribu added

#2 @adambackstrom
13 years ago

  • Cc adambackstrom added

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

@adambackstrom
13 years ago

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

@adambackstrom
13 years ago

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

@adambackstrom
13 years ago

Prevent wp_mkdir_p from stripping after the URL scheme

@adambackstrom
13 years ago

Prevent wp_mkdir_p from stripping // after the URL scheme

#3 @nacin
12 years ago

  • 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.

#4 @Japh
12 years ago

  • Cc japh@… added

#5 @wonderboymusic
12 years ago

  • Keywords has-patch added

#6 @markoheijnen
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [22094]

#7 @markoheijnen
12 years ago

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