Closed littlefyr closed 10 years ago
Could you point me to the code you are using for the logo?
Its been a little while since I worked on this part (life and all that) but I think this is it:
In the customize_register
action I have this code:
$wp_customize->add_setting($this->setting_name('logo'), array(
'transport' => 'postMessage',
'default' => ''
));
$wp_customize->add_control(
new LF_Customize_Image_Control(
$wp_customize,
$this->setting_name('logo'),
array(
'label' => __( 'Upload a logo', 'theme_name' ),
'section' => 'title_tagline',
'settings' => $this->setting_name('logo')
)
)
);
And that custom image control simply wraps the default to more nicely handle the file upload:
<?php
//Sourced from https://gist.github.com/eduardozulian/4739075/
class LF_Customize_Image_Control extends WP_Customize_Image_Control {
/**
* Constructor.
*
* @since 3.4.0
* @uses WP_Customize_Image_Control::__construct()
*
* @param WP_Customize_Manager $manager
*/
public function __construct( $manager, $id, $args = array() ) {
parent::__construct( $manager, $id, $args );
}
/**
* Search for images within the defined context
*/
public function tab_uploaded() {
$my_context_uploads = get_posts( array(
'post_type' => 'attachment',
'meta_key' => '_wp_attachment_context',
'meta_value' => $this->context,
'orderby' => 'post_date',
'nopaging' => true,
) );
?>
<div class="uploaded-target"></div>
<?php
if ( empty( $my_context_uploads ) )
return;
foreach ( (array) $my_context_uploads as $my_context_upload ) {
$this->print_tab_image( esc_url_raw( $my_context_upload->guid ) );
}
}
}
Is there custom upload functionality? I don't see where it actually uploads the image. Code looks like it configures some settings, and retrieves some posts.
I need to see what the data looks like as it's going in and hopefully an output of what the image object looks like.
This is just the Theme customization api http://codex.wordpress.org/Class_Reference%5CWP_Customize_Manager%5Cadd_control
Oh duh - ok yeah I'll mess with this in a few hours
On Sep 4, 2014, at 11:10 PM, Adam van den Hoven notifications@github.com wrote:
This is just the Theme customization api http://codex.wordpress.org/Class_Reference%5CWP_Customize_Manager%5Cadd_control
— Reply to this email directly or view it on GitHub.
There seems to be part of an answer here
Nice. I'll give that a try. I think that's enough to get it done.
@Scrupulosis is correct. This is the proper approach.
Here's my test.
https://gist.github.com/grok/52343cb93cca482c0796
Prior to adding $this->extensions = array('jpg', 'jpeg', 'gif', 'png', 'svg');
I was unable to upload SVG files. After adding that I was able to.
Ok. That's great. Thanks.
This plugin is awesome sauce. I'm going to be using it everywhere.
One thing I noticed, however, is that this does not work with my theme customization. Which is to say that when I add a theme setting for "Logo" I can't upload an SVG logo to that.
I'm hoping to share this theme via WP so I'm not going to bake all this logic into my theme, but I want to let others who may want to use SVG are able to without having to jump through hoops to get there.