Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i know this is a bit of a weird question but its a real time saver
so if you got any ideas (even partial) i would really apreacate them :)

Ok... so i am using wordpress built in interface to capture and disply
remote website images... here is the shortcode i am using..

/*********************************************************************
** SNAPSHOTS
*********************************************************************/
function wpr_snap($atts, $content = null) {
        extract(shortcode_atts(array(
            "snap" => 'http://s.wordpress.com/mshots/v1/',
            "url" => 'http://www.sagive.co.il',
            "alt" => 'My image',
            "w" => '400', // width
            "h" => '300' // height
        ), $atts));

    $img = '<img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '"/>';
        return $img;
}

add_shortcode("snap", "wpr_snap");

(How to use this: http://wordpress.stackexchange.com/a/38293/7990) .

thats easy no problem.. but - what if i want to integrate it with lightbox.. since its not an image hosted on my website is ther any way to access that images or even write somthing that would upload the image and make it the feautred image of that specific post (a strech i know) or maybe store it elsewhere somehow? (without a plugin)..

to try and grab the image i have made a second shortcode that does the same snapshot but doesnt wrap inside image tag for the href with the lightbox class..
.

this is the line in the theme:

<a class="lightImages" href="<?php echo do_shortcode('[snapurl url="http://www.sagive.co.il"]'); ?>"><?php echo do_shortcode('[snap url="http://www.sagive.co.il" w="175px" h="125px" alt="'.get_the_title().'"]'); ?></a>

.
any ideas?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted
+50

EDITED ANSWER

Forget every thing i said before. Here is what i have found the following

  1. In php to generate a website thumbnail, you cant do it natively with php's built in functions, so you have to call an external service or program to do it for you. Since wordpress is basically php , this fact still holds true. You can see for yourself other coders struggling to do so here :) . I believe that at the url http://s.wordpress.com/mshots/v1/ there exists such a service.
  2. To use the service above eg to get a snapshot of google.com

    http://s.wordpress.com/mshots/v1/http%3A%2F%2Fwww.google.com%2F?w=300px&h=200px
    Note that the url has to be properly encoded thats why you see funny characters in the url

Now light box.

  1. Is a javascript script that allows you to have cool picture effects and is easy to use. The implementation i decided to use is a wordpress plugin called Lightbox Plus which depends on colorbox (just another variant of lightbox)
  2. Colorbox tries to do some kind of automatic automatic photo detection which may fail in a case like ours where we reference php files instead of direct images or so i think :) See this question on stackoverflow. For my case the problem is because colorbox has code like this somewhere

var defaults = { photo: false; }

Solution Change the false to true :)
Details

  1. Download colorbox
  2. Get the file jquery.colorbox.js and copy it to the plugin js folder right next to jquery.colorbox-min.js
  3. Edit jquery.colorbox.js by changing photo:false to true
  4. Tell our plugin to use the modified file. by modifying lightbox-plus\classes\actions.class.php and replace all references to jquery.colorbox-min.js with jquery.colorbox.js

Fix your shortcode. Here is the one iam currently using BUT it only generates images of my schools website

function wpr_snap($atts, $content = null) {
        extract(shortcode_atts(array(
            "snap" => 'http://s.wordpress.com/mshots/v1/',
            "url" => 'http://www.sagive.co.il',
            "alt" => 'My image',
            "w" => '400', // width
            "h" => '300' // height
        ), $atts));

    $img = '<a rel="lightbox[roadtrip]" href="http://s.wordpress.com/mshots/v1/http%3A%2F%2Fchs.mak.ac.ug%2F?w=300px&amp;h=200px"><img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '" style="border:1px solid #333;padding:2px;"/></a>';
    return $img;
}

add_shortcode("snap", "wpr_snap");

This is what i see in admin area How it looks

Good luck.

share|improve this answer
    
thanks for help but the lightBox works like this: <a class="lightImages" href="THE_IMG_URL_HERE"><img here -- the shortcode returns></a> .... I actually created to shortcodes.. becuse - one retunrs a complete <img .. > tag and the other only the adress of the images but since wordpress generates this image i the adress doesent work.. looking how to make it work or a similer solution where the snapshot is automated.. –  Sagive SEO Feb 29 '12 at 18:49
    
The image is generated by a remote php service, Not wordpress –  Dr Deo Mar 1 '12 at 10:42
    
going to try your example :) b back soon.. back –  Sagive SEO Mar 1 '12 at 20:40
    
There you go... a major bump in your points :) gr8 descriptive answer! thanks a lot mate :) –  Sagive SEO Mar 1 '12 at 21:23
add comment

Accessing the image via Lightbox isn't a problem. While you might run into performance concerns and, of course, you don't have ultimate control over the contents of the image (it could go down), there isn't a technical problem with loading the image via Lightbox.

Grabbing an image remotely and setting it to a featured thumbnail isn't a huge stretch, but should probably be thought of a different way.

Take a look at this question for an idea: (http://wordpress.stackexchange.com/questions/29198/add-post-thumbnail-from-external-image-with-plugin

share|improve this answer
    
thats very intresting but i dont know how to grab the image i get ftom the snapshot function so i could manipulate it.. got any ideas as to how to do that? –  Sagive SEO Feb 27 '12 at 3:51
    
That's beyond what I can offer right now. Someone else may have a code sample. Otherwise, I'd encourage you to get coding and if you get stuck along the way, head on back and we can help you to the next part. –  Jonathan Wold Feb 27 '12 at 3:55
    
10x for trying to help... thats actually the part i am stuck on and not for lack of searching.. –  Sagive SEO Feb 27 '12 at 4:03
    
Do you think the Lightbox hotlinking method might get the job done for you? It'd be a lot simpler to tackle. –  Jonathan Wold Feb 27 '12 at 4:04
    
(apologies) what does hotlinking in regards to lightbox means? –  Sagive SEO Feb 27 '12 at 16:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.