wp_query get attachments in larger size

If you look at the raw post data… while (have_posts() ) { the_post(); ?> <article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>><?php var_dump($post); ?> </article><?php } You will see that there is nothing in there to specify “medium”, so I went looking. There is a filter on the_content… add_filter( ‘the_content’, ‘prepend_attachment’ ); … that juggles data … Read more

All attachment pages give 404

Actually I got to the bottom of it. The problem was that I have installed the WPML plugin. But I forgot to install the WPML Media plugin. As soon as I installed it, the attachment pages started working again. In my opinion, this is unacceptable and I will escalate the issue to WPML team. If … Read more

Upload multiple image with media_handle_upload with multiple file field [duplicate]

You can try adding the input file field once and using then using jQuery to add more fields when clicking add more. Here are the steps Register your setting using register_setting function Create Menu using add_menu_page. This also requires a calback function Add the thickbox and media-upload script using wp_enqueue_script and wp_enqueue_style Use the call … Read more

how to get attached file url for current post?

try get_pages with ‘child_of’ => get_the_ID(), ‘parent’ => get_the_ID(), If you need i can post full code EDIT : if ( is_singular(‘post’) ) { $args = array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => null, ‘parent’ => $post->ID , ‘child_of’ => $post->ID, ‘sort_order’ => ‘desc’ ); $attachments = get_pages( $args ); if ( $attachments … Read more

Adding metaboxes to attachment pages

get_post_meta returns an array when you set the 3rd parameter to false, so $value is an array in your metabox callback and you’re treating it as string. I assume an attachment has a single value for license, so you want to set that to true instead.

How do I intercept and modify the functionality of wp_get_attachment_image()?

It might be a solution to string replace /wp-content/uploads with ” (empty) like for an example: Lets say: wp_get_attachment_image() returns=”/wp-content/uploads/myimage.png”; <?php echo str_replace(‘/wp-content/uploads/’, ”, wp_get_attachment_image()); ?> This will result in echo: ‘myimage.png’ Try this: function alter_image_src($attr) { $attr[‘src’] = str_replace(‘/wp-content/uploads/’, ”, $attr[‘src’]); return $attr; } add_filter( ‘wp_get_attachment_image_attributes’, ‘alter_image_src’); In your functions page (of theme).

Echo list attachment size in post

wp_get_attachment_thumb_url() doesn’t accept three parameters. It takes one– the attachment ID. And, as you might guess from the name of the function, it return the thumbnail URL *_thumb_url. If you’d have simply checked the Codex entry for the function you’d have seen that. If you’d check the Codex, you’d see several other things too Don’t … Read more

wp_generate_attachment_metadata for non-images files

wp_generate_metatadata() should create metadata for image, video, and audio file types. There is and if/elseif conditional in the source that limits the function to those three. However, the last line is: return apply_filters( ‘wp_generate_attachment_metadata’, $metadata, $attachment_id ); So you could use the wp_generate_attachment_metadata filter to generate the metadata you want. There are plenty of answers … Read more

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