Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter sacredrider

    (@sacredrider)

    So far i have made changes to template_tags.php:

    $href = '<a href="';
    $hrefend = '">';
    $aend = '</a>';
    
    echo $href . $info[0] . $hrefend . $beforeUrl . $info[0] . $afterUrl . $aend;

    The issue now is selecting a thumbnail for initial and medium or large for the enlarge.

    Is there a way i can specify from here if i want a thumbnail or large instead of the one in the actual page being the reference?

    What i am thinking is something like:
    $info[0]->large and $info[0]->thumbnail

    Thread Starter sacredrider

    (@sacredrider)

    Another potential is :

    $info = wp_get_attachment_image_src($attachment->ID, $size);
     $info2 = wp_get_attachment_image_src($attachment->ID, large);
    echo $href . $info2[0] . $hrefend . $beforeUrl . $info[0] . $afterUrl . $aend;

    This works, but then i get errors when uploading the image. I cant get pas this bit.

    Thread Starter sacredrider

    (@sacredrider)

    The errors i am getting are:

    Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/sacred/public_html/example.com/wp-includes/media.php on line 937

    Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/sacred/public_html/example.com/wp-includes/class-wp-image-editor-gd.php on line 162

    Warning: Cannot modify header information – headers already sent by (output started at /home/sacred/public_html/example.com/wp-includes/media.php:937) in /home/sacred/public_html/example.com/wp-includes/pluggable.php on line 876

    Hello,

    First of all this is a damn great plugin! Great work and keep it up!

    Just to clarify, as I think this post was resolved but the solution not clear to everybody. I modified the template-tags.php file located in the library directory of the user-submitted-posts plugin directly.

    The following works perfectly, with one or multiple images to display in a “slideshow” using WP Lightbox 2 (another great plugin). Here are the changes (included between FIX and EOF, basically a miserable one line addition + a change in the returned string of the echo call:

    function usp_post_attachments($size = 'full', $beforeUrl = '<img src="', $afterUrl = '" />', $numberImages = false, $postId = false) {
    	if (false === $postId) {
    		global $post;
    		$postId = $post->ID;
    	}
    	/*if (!in_array($size, array('thumbnail', 'medium', 'large', 'full'))) {
    		$size = 'full';
    	}*/
    	if (false === $numberImages || !is_numeric($numberImages)) {
    		$numberImages = 99;
    	}
    	$attachments = get_posts(array('post_type'=>'attachment', 'post_parent'=>$postId, 'post_status'=>'inherit', 'numberposts'=>$numberImages));
    	foreach ($attachments as $attachment) {
    // FIX for supporting LightBox with WP-LightBox 2
    		$info = wp_get_attachment_image_src($attachment->ID, $size);
    		$lightBoxedUrl = wp_get_attachment_image_src($attachment->ID, 'large');
    		echo '<a href="' . $lightBoxedUrl[0] . '" rel="lightbox[uspgallery]">' . $beforeUrl . $info[0] . $afterUrl . '</a>';
    // EOF
    	}
    }

    I don’t like to modify plugins code directly, for obvious plugins upgrade reasons, therefore, a “clean” way, more painful though would be to actually create a function in your theme to deal with this, but for the purpose of the site I am working on, it’s far enough and works as expected 100%.

    Jeff, I suggest you an option for lightbox support to usp_post_attachments() given lightbox is widely used everywhere.

    Keep the good work up!

    Cheers,
    RaPhiuS

    Plugin Author Jeff Starr

    (@specialk)

    Thanks RaPhiuS! I’m looking at adding lightbox support in the upcoming Pro version of User Submitted Posts. Thanks for the suggestion!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Lightbox’ is closed to new replies.