Make WordPress Core

Opened 15 years ago

Closed 14 years ago

Last modified 14 years 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: Focuses:

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

Download all attachments as: .zip

Change History (13)

#1 @scribu
15 years ago

  • Cc scribu added

#2 @adambackstrom
15 years ago

  • Cc adambackstrom added

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

@adambackstrom
15 years ago

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

@adambackstrom
15 years ago

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

@adambackstrom
15 years ago

Prevent wp_mkdir_p from stripping after the URL scheme

@adambackstrom
15 years ago

Prevent wp_mkdir_p from stripping // after the URL scheme

#3 @nacin
14 years ago

  • Milestone Awaiting Review → 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
14 years ago

  • Cc japh@… added

#5 @wonderboymusic
14 years ago

  • Keywords has-patch added

#6 @markoheijnen
14 years ago

  • Resolution → fixed
  • Status new → closed

Fixed in [22094]

#7 @markoheijnen
14 years ago

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