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

Add custom field to image editor

To add a custom field to attachments, place the following code in your functions.php. add_filter(‘attachment_fields_to_edit’, ‘edit_media_custom_field’, 11, 2 ); add_filter(‘attachment_fields_to_save’, ‘save_media_custom_field’, 11, 2 ); function edit_media_custom_field( $form_fields, $post ) { $form_fields[‘custom_field’] = array( ‘label’ => ‘Custom Field’, ‘input’ => ‘text’, ‘value’ => get_post_meta( $post->ID, ‘_custom_field’, true ) ); return $form_fields; } function save_media_custom_field( $post, $attachment … Read more

How do I change the description of the same image which is to be found in multiple instances?

Plugin idea #1 When we insert an image into the editor, the plugin automatically modifies the caption and the alt attribute to: Then on the front-end the image caption is fetched for the corresponding image attachment, based on the attachment_729 string and replaces the ###ALT### and ###CAPTION### dummy values. So when we want to modify … Read more

Extract image src from a post and send it to an external form

There is no built-in way to extract an image/image-src from the post body. If the images are attachments you can do it with get_children or WP_Query, and wp_get_attachment_image_src. function get_image_src_from_content_101578($content) { global $post; $args = array( ‘post_parent’ => $post->ID, ); $images = get_children($args); foreach ($images as $img) { var_dump(wp_get_attachment_image_src($img->ID)); } } add_action(‘the_content’,’get_image_src_from_content_101578′); You could also … Read more