How do I ‘rebuild’ the WordPress Media library after transfer to new host?

There’s a few plugins to fix this, but basically it your database still references the images to be “oldsite.com/wp-content/uploads/” and you need it to be “newsite.com/wp-content/uploads” So you have to change all old references. You could use SQL: UPDATE wp_options SET option_value = replace(option_value, ‘http://www.oldsite.com’, ‘http://www.newsite.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’; UPDATE … Read more

image_size_names_choose filter doesn’t show

No, that seems to work right. You could test it by doing <?php echo get_the_post_thumbnail(‘grade-image’); ?> try this. add_image_size( “grade-image”, 320, 300, true ); add_filter( ‘image_size_names_choose’, ‘my_custom_sizes’ ); function my_custom_sizes( $sizes ) { return array_merge( $sizes, array( ‘grade-image’ => __(‘Grade Image’), ) ); }

Bind event on Media gallery elements WordPress

(function ($) { “use strict”; $(function () { var button = $(‘.upload-image’); button.click(function (e) { e.preventDefault(); // If the media frame already exists, reopen it. if (file_frame) { file_frame.open(); return; } var btn = $(this), media = wp.media; // Create the media frame. var file_frame = media.frames.file_frame = media({ title: jQuery(this).data(‘uploader_title’), button: { text: jQuery(this).data(‘uploader_button_text’) … Read more

WordPress 3.5 attachment_fields_to_edit and media_send_to_editor

So, there are some things which work differently (now). I. What you’ve noticed, when you click the checkbox WordPress sends an Ajax request to ‘wp_ajax_save_attachment_compat()’ with some form data, if your checkbox is checked, this information will be part of the form data. ‘wp_ajax_save_attachment_compat()’ checks for $_REQUEST[‘attachments’] and $_REQUEST[‘attachments’][$id] and will fail if it does … Read more

print_media_templates not applied in media manager plugin

Ok I’ve figured some things out by now: I was not returning the rendered image into anything In the javascript I have a render function media.view.AttachmentsBrowser = media.view.AttachmentsBrowser.extend({ render: function(){ var that = this; if(this.collection){ if(this.collection.models.length > 0){ this.clearImages(); _.each(this.collection.models, function (item){ //old way: that.renderImage(item); //now: this.$el.find(‘#lastli’).before(that.renderImage(item)); }, this); } } } }); Obviously my … Read more