Separate attachment images from post loop

The best way to assign images to a given post is to just upload them in the WordPress post editing/new post area. You can also delete images from there. With that said, here would be how you do that. You’re going to hook into wp_enqueue_script, and call wp_enqueue_script to add your gallery script to the … Read more

How to remove title attribute from gallery links and images

I’ve found a solution : // Remove <img> title attribute in // http://wordpress.org/support/topic/wp_get_attachment_image_attributes-filter-not-working function remove_img_title($atts) { unset($atts[‘title’]); return $atts; } add_filter(‘wp_get_attachment_image_attributes’,’remove_img_title’, 10, 4); // remove title attribute from <a> title attribute in // modified from this post : http://oikos.org.uk/2011/09/tech-notes-using-resized-images-in-wordpress-galleries-and-lightboxes/ function ah_get_attachment_link_filter( $content ) { $new_content = preg_replace(‘/title=\'(.*?)\”https://wordpress.stackexchange.com/”, ”, $content ); return $new_content; } add_filter(‘wp_get_attachment_link’, ‘ah_get_attachment_link_filter’, … Read more

When inserting images into posts auto add a wrapping div

I think it is a better idea, if you filter the output, the the_content and add the div on all images. It is better for feature, if you will remove this markup, it is not inside the database. add_filter( ‘the_content’, ‘fb_add_div_to_img’ ); function ( $content ) { // find img and add markup return $content; … Read more

Setting up a gallery with images and a zip download

You can use the built-in functionality to solve this: The WordPress Gallery. Each post and page (and normally custom types) can have files of all kind attached to it. You upload them through the Add Media button, and have the option to make a Gallery with the images attached to this post/page or with other … Read more

How can I serve different images depending on screen size with wordpress

add_image_size does change the actual size of the image file. What I hava tried: function odevice_image_sizes() { add_image_size( ‘iphone-size’, 300, 100, true );//OF course the dimensions are not correct… add_image_size( ‘tablet-size’, 600, 300, true ); } function show_odevice_at_img_select($sizes) { $sizes[‘iphone-size’] = __( ‘Image size for iphone’ ); $sizes[‘tablet-size’] = __( ‘image size for tablet’ ); … Read more

Alter media caption/description conflict in WordPress?

I wonder if this will work for you: add_action( ‘add_attachment’, function( $attachment_id ){ $a = get_post( $attachment_id ); if ( is_object( $a ) && ‘image’ === substr( $a->post_mime_type, 0, 5 ) ) wp_insert_attachment( array( ‘ID’ => $a->ID, ‘post_excerpt’ => $a->post_content ) ); }); or with less queries: add_action( ‘add_attachment’, function( $attachment_id ){ global $wpdb; if( … Read more

Crop image to horizontal or vertical by code based on image size

why didn’t use add_image_size( ‘horizontal_img’, 800, 300, true ); add_image_size( ‘vertical_img’, 300, 800, true ); And then $image_hor = wp_get_attachment_image_src($post_id,’horizontal_img’); $image_ver = wp_get_attachment_image_src($post_id,’vertical_img’); when echo $image_hor[0] you will get your desire sized image url. Thanks Musa

Insert Images at Master Uniform Height

There are multiple solutions: Use CSS for post images: .post img { height: 300px; width: auto; } Use a custom thumbnail size. Either in Settings -> Media or use a third-party plugin to generate them. Another way would be to code your own: function custom_image_sizes() { add_theme_support(‘post-thumbnails’); add_image_size(‘breaking-news’, 9999, 300, true); } function add_custom_sizes( $imageSizes … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)