- This topic is empty.
-
AuthorPosts
-
March 23, 2011 at 11:41 am #32101infocentreMember
As the title says, i would like a nice bit of coding to stick in my functions that pre-loads any images that are attached to the next post.
This means that whilst my users are browsing, they page will load, but it will actually be loading the next page, so when you click-through, the images should already be there and waiting!
Think of it as ‘buffering’ for image.
Anyone got any thoughts on this?
Cheers!
March 23, 2011 at 12:22 pm #54428TheDocMemberHmmmmm – if it’s literally loading a new page, I’m not sure that can be done as the script that you’re using won’t know what the “next” page is.
Certainly possible with AJAX if you made all pages load at once and then the user just cycles through them, but that has bookmarking issues that would preferably be avoided.
Not sure if you can do this. Maybe somebody has some Javascript inspiration that I don’t.
March 23, 2011 at 12:40 pm #54430infocentreMemberI figured it is a pretty tall ask – but there must be a way of gathering the Next post ID and it’s attached Featured image/images.
I did come across this which is kind of on the right lines:
function twpw_imagepreload() {
$args3=array(
'post_status'=>'publish'
);
$imageloader= null;
$imageloader = new WP_Query();
$imageloader->query($args3);
$imagepreload.='';';
if ($imageloader->have_posts()) : while ($imageloader->have_posts()) : $imageloader->the_post();
$parentid=get_the_ID();
$args1=array(
'post_type'=>'attachment',
'post_parent' => $parentid,
'post_mime_type' => 'image'
);
$image_query = get_children($args1);
foreach ( $image_query as $attachment_id => $attachment ) {
$image3=wp_get_attachment_image_src($attachment_id);
$imagepreload.='';
}
endwhile; endif;
$imagepreload.='
return $imagepreload;
}It’s purpose is to load ALL attached images, but it times stops after loading the first 6 (i think), not sure why.
Any other suggestions as to how i could achieve this, or something similar?
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.