Unattaching images from a post

This can be done using an Ajax call that will query the database and set the parent as “zero”. First, create a meta box, enqueue the Javascript that calls the unattach function and register this WP_Ajax function. <?php /* Plugin Name: Unattach Meta Box Version: 0.3 Author: brasofilo Plugin URI: http://wordpress.stackexchange.com/q/54822 */ add_action( ‘add_meta_boxes’, ‘wpse_54822_add_custom_box’ … Read more

Dynamic-Image-Resize Plugin does not output anything

Ask the right guy Which you just did, so… here’s your answer from the developer. 🙂 What does the right output tell us? First of all, the public dynamic_image_resize() API function is just a wrapper for the singleton itself. When you take a closer look at the class, you’ll notice a __toString() method, which is … Read more

Change Default Image HTML

This will do: <?php /* * This filter only works with images, for all kind of media check: media_send_to_editor * The priority is set to 20 and it takes 8 arguments */ add_filter(‘image_send_to_editor’, ‘wpse_53577_img_wrapper’, 20, 8); // We are only working with the $html argument, but you can play with all of them function wpse_53577_img_wrapper($html, … Read more

How to add php to theme to show alt attributes

Try adding these codes to your theme’s function.php file: function isa_add_img_title( $attr, $attachment = null ) { $img_title = trim( strip_tags( $attachment->post_title ) ); $attr[‘title’] = $img_title; $attr[‘alt’] = $img_title; return $attr; } add_filter( ‘wp_get_attachment_image_attributes’,’isa_add_img_title’, 10, 2 );

Removing Image Sizes for Custom Post Type

May be this filter should work intermediate_image_sizes Note: This solution will work if you are uploading an image from post edit screen. (tested on localhost with WP-3.8.1) add_filter( ‘intermediate_image_sizes’, ‘ravs_slider_image_sizes’, 999 ); function ravs_slider_image_sizes( $image_sizes ){ // size for slider $slider_image_sizes = array( ‘your_image_size_1’, ‘your_image_size_2’ ); // for ex: $slider_image_sizes = array( ‘thumbnail’, ‘medium’ ); … Read more

Prevent Width and Height Attributes in Image Tag Output

Use wp_get_attachment_image_src() and build a simplified img element. You may use something like the following code as a replacement for wp_get_attachment_image(): function wpse_53524_get_image_tag( $attach_id, $size, $icon, $alt=”” ) { if ( $src = wp_get_attachment_image_src( $attach_id, $size, $icon ) ) { return “<img src=”https://wordpress.stackexchange.com/questions/53524/{$src[0]}” alt=”$alt” />”; } } Put the function above into your theme’s functions.php. … Read more

How to make Next and Previous attached image navigation on the attachment page? [duplicate]

Use previous_image_link and next_image_link in a image.php or attachment.php file. <nav id=”image-navigation” class=”navigation image-navigation”> <div class=”nav-links”> <?php previous_image_link( false, ‘<div class=”previous-image”>’ . __( ‘Previous Image’, ‘$text_domain’ ) . ‘</div>’ ); ?> <?php next_image_link( false, ‘<div class=”next-image”>’ . __( ‘Next Image’, ‘$text_domain’ ) . ‘</div>’ ); ?> </div><!– .nav-links –> </nav><!– #image-navigation –> Source: Twenty Fourteen