How to load previous or next attachment with jquery ?

@milo thanks ! i used a technique found on the page you sent. it’s almost working. I added this at the end of the previous single.php code : array_unshift($attachments_list,””); wp_enqueue_script(‘myscript’); wp_localize_script(‘myscript’, ‘attachments_list’, $attachments_list); To work, this code must be called before wp_head(). Then, for a mysterious reason, the first element (with the index 0) is … Read more

How can I rewrite old attachment URLs?

Figured it out! The function I needed to hook is called “the_content”, because that’s the post content that is pulled directly from the database. I added this code into the functions.php file for my theme. function force_https_the_content($content) { if ( is_ssl() ) { $content = str_replace( ‘src=”http://’, ‘src=”https://’, $content ); } return $content; } add_filter(‘the_content’, … Read more

i want attachment.php to return the image

Answer is this (thanks to WordPress Vampire here : Change Attachment Post URLs to File URLs) : Create an attachment template file within the theme. Since we are only interested in images, the file should be image.php <?php if ( have_posts() ) { the_post(); $image_url = wp_get_attachment_url(); } header(‘Location: ‘.$image_url); ?>

changing the default picture size link url

You can use: <?php $image_attributes = wp_get_attachment_image_src( $attachment_id, array(1024,1024) ); ?> <a href=”https://wordpress.stackexchange.com/questions/37124/<?php echo $image_attributes[0]; ?>”>xxx</a> See http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src If the picture is too small the original will show, otherwise cropped version (1024×1024). Update: Didn’t understand your question correct. Here is what you need: First of all add a thumbnail size for your custom max size … Read more

custom url – add attachment’s id or name after post

Showing links to attachments in the desired format Loop through the attachments and generate the link you want: $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => null, ‘post_status’ => null, ‘post_parent’ => $post->ID ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { echo ‘<a href=”‘ . get_permalink() . ‘video/’ . $attachment->ID . … Read more