How to wrap this Link with an Image?

Try passing in the image into the functions themselves: <?php $previous_image = “<img src=”http://domain.com/path/to/image/” alt=”Previous Posts”>”; $next_image = “<img src=”http://domain.com/path/to/image/” alt=”Newer Posts”>”; ?> <span class=”nav-previous”><?php previous_image_link( false, $previous_image ); ?></span> <span class=”nav-next”><?php next_image_link( false, $next_image ); ?></span>

Showing the attachment for a page?

Use, wp_get_attachment_image_src( $attachment_id, $size); Specify the size parameter as follows; $size (string/array) (optional) Size of the image shown for an image attachment: either a string keyword (thumbnail, medium, large or full) or a 2-item array representing width and height in pixels, e.g. array(32,32). As of Version 2.5, this parameter does not affect the size of … Read more

ID of images from gallery

You can find out the IDs of which images are included in a gallery by switching to the Text editor tab and look for a piece of code like this: The comma-separated list of image IDs are enclosed in the ids attribute If you’re looking to find out IDs of existing images in order to … Read more

What is the most efficient way to retrieve a group of image URL’s from different attachment ID’s of a specific crop size?

I don’t believe there is more efficient way. Your primary object should be keeping things simple while using WP’s API which is exactly what you’re already doing. It’s true some scenarios could become pretty expensive and that is where you could take advantage of WP Object Cache or even Transients API. A good example of … Read more

How to retrieve images contained in a post

I’m guessing you’ll need to fetch the post content and parse it using something like this as a guide (pasted code from above link for future reference). // Get the all post content in a variable $posttext = $post->post_content; $posttext1 = $post->post_content; // search for the src=”” in the post content $regular_expression = ‘~src=”[^”]*”~’; $regular_expression1 … Read more

How to get boolean if file A is attached to post B

Get all attachments: $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ) ); Check attachment “parent” for each attachment. foreach($attachments as $attachment){ $parentID = $attachment->post_parent; $postID = $post->ID; if($parentID == $postID){ //your code here echo ‘This attachment belongs to the current post.’; } } But if you already have the attachment, all you … Read more

How can I let users access a specific attachment?

WordPress (or more precisely its .htaccess or alternate web server configuration file) passes through requests to existing files. The easiest way would be to start at root of your site and (using FTP/SFTP/hosting admin panel/etc): create blank01 folder create blank02 subfolder in it place file.xml into subfolder And it should just work, link will point … Read more

Custom attachment field dissapearing

I figured it out. In an effort to organize/optimize my actions and filters, there are a bunch that I only call on certain pages, using WordPress’ global $pagenow variable. I was only calling the “attachment_fields_to_edit” filter for media-upload.php, async-upload.php, and media-new.php, which apparently isn’t a valid way to do this with the new uploader. I … Read more