Make WordPress Core

Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#27118 closed enhancement (duplicate)

WP_Customize_Image_Control should return attachment ID instead of image URL

Reported by: silb3r's profile silb3r Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8.1
Component: Customize Keywords:
Focuses: Cc:

Description

WP_Customize_Image_Control should, by default, return an attachment ID instead of an image URL.

Change History (6)

#1 @johnbillion
11 years ago

  • Milestone changed from Awaiting Review to Future Release

Yes yes yes yes yes! This has caused me no end up trouble over the last few weeks. Unfortunately what we will need to do is create a new customizer control so we maintain backward compatibility in the WP_Customize_Image_Control class. Either that or introduce a parameter to that class which indicates it should store and return an attachment ID.

#2 @tollmanz
11 years ago

I recently learned that another reason why this is so important is that if you queue up an image control and save the data in a theme mod, the mods become tough to transfer to a different domain due to the serialization of the theme mod array. Protecting against this would be really excellent.

#3 @alan-dale
10 years ago

I agree. I have been working more with the customization API and it would be nice to be able to use images sized specifically for headers and the like. And as tollmanz said, if you develop using the dev/staging/production server method, serializing the URL into the data makes transferring your settings across environments less than ideal. Maybe in a new release of 4.0?

#4 @ocean90
10 years ago

  • Component changed from Options, Meta APIs to Customize

#5 @celloexpressions
10 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Sadly, we can't do this for back compat purposes. The proposed WP_Customize_Media_Control (#29215) would allow us to essentially duplicate the functionality of the new WP_Customize_Upload_Control (and by extension the image control) but store the attachment id or other data rather than the file url directly. Also worth noting that core currently has to use attachment_url_to_postid() to facilitate this, and that workaround could be an option in themes and plugins as well. Let's move this discussion to #29215.

Related: #21483.

#6 @rodrigosprimo
10 years ago

Anyone has a workaround to get the ID of the attachment while WP_Customize_Media_Control is not created?

Note: See TracTickets for help on using tickets.