WordPress.org

Ready to get started?Download WordPress

Forums

Wordbooker
Problem with WPG2 images (12 posts)

  1. wsitch
    Member
    Posted 3 years ago #

    Hi Steve,

    I just switched over from Robert's Wordbook to your excellent Wordbooker. Significant improvements; thanks very much for taking this on - you've done a fantastic job.

    I looked through the code and noticed that my WPG2 addition made it into your code, but unfortunately something isn't working properly. I wonder if I could beg you to look into this further.

    WPG2 is a tool that connects Gallery2 with WordPress. Gallery2 is an image storage database. The three work really well together, and the missing link is your software that takes a blog post and shoots it off to Facebook.

    In the WordPress post, I add images with the WPG2 chooser, which adds html-like tags as follows:

    test1
    <wpg2>3975</wpg2>
    test2
    <img src=...
    test3

    This tag should be translated into the HTML link as I wrote on your blog way back in May: http://blogs.canalplan.org.uk/steve/2010/05/19/revisiting-old-code/

    What's happening is unclear. I turned on the advanced diagnostics and get the following:

    2010-10-11 13:53:50 Post Images : http://will.sitch.org/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=2296&g2_serialNumber=2 ( )
    2010-10-11 13:53:50 Post Images : http://will.sitch.org/blog/wp-content/uploads/2010/10/IMG_3757-300x200.jpg ( )

    (the first link is a WPG2 link, the second is one added with the WordPress "add an image" interface)

    The post that goes to facebook looks like this:

    (pic of the img_3757, added through the wordpress interface)test1 3975 test2

    So for some reason the WPG2 image reference is being sent through as text; it's not being decoded as a link!

    Ideas? I'd love to get this working.

    Thanks,
    Will

    http://wordpress.org/extend/plugins/wordbooker/

  2. wsitch
    Member
    Posted 3 years ago #

    So I see two issues:

    1. The image URL is reported correctly in the debug section:
    http://will.sitch.org/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=2296&g2_serialNumber=2

    But the image doesn't show up in the facebook post.

    2. The image tag number IS showing up in the facebook post (the text of which is:
    test1 3975 test2

    In wordbooker.php, it looks like one possibility could be the json_encode of the $attachment block:

    $result = $fbclient->stream_publish($message,json_encode($attachment), json_encode($action_links));
    wordbooker_debugger("Publish to Personal wall result : ",$result,$post->ID) ;

    I get the result:

    2010-10-11 13:53:51 Publish to Personal wall result : ( 543335236_10150269320925237 )

    Does the json_encode allow URLs with embedded variables? It should. I dunno, I'm grasping at straws here.

    Thanks,
    Will

  3. Steve
    Member
    Plugin Author

    Posted 3 years ago #

    The Json encode should take anything as a valid URL. IF the json encode wasn't working properly then you wouldn't get a FB ID returned.

    However that doesn't mean that FB is processing the image.

    As for the WPG2 tag getting pulled through as text - it probably needs me to code it into my strip_tags process which pulls out all sorts of extra bits.

    I had problems with WPG2 last time I tried to use it and I've not been doing much dev work recently as I've been pulling 50+hour working weeks.

  4. wsitch
    Member
    Posted 3 years ago #

    Hi Steve,

    Yep, I'm figuring that out too. I put in some debug code and get the following:

    JSON attachment : {"name":"test2","href":"http://will.sitch.org/blog-archive/2010/10/test2","description":"test2 3975 test3","media":[{"type":"image","src":"http://will.sitch.org/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=3977&g2_seri

    I'm assuming it's being truncated by the diagnostics display, which BTW is a fantastic feature. Makes debugging a hell of a lot easier!

    The URL in the img src looks correct. Is there any way to read back what facebook accepted as the post and display that as a debug line?

    Thanks,
    Will

  5. wsitch
    Member
    Posted 3 years ago #

    Okay, the stupid facebook stream attachment isn't accepting media URLs with parameters.

    will.sitch.org/gallery2/blah.jpg works
    will.sitch.org/gallery2/?img=blah.jpg doesn't

    This sucks.

  6. Steve
    Member
    Plugin Author

    Posted 3 years ago #

    So I'd need to find any WPG2 image tags and work out the real image file path and load that into the image array.

    Its messy but I can probably do it - I've managed to do it with Youtube thumbnails so.....

  7. Steve
    Member
    Plugin Author

    Posted 3 years ago #

    So I'd need to find any WPG2 image tags and work out the real image file path and load that into the image array.

    Its messy but I can probably do it - I've managed to do it with Youtube thumbnails so.....

  8. wsitch
    Member
    Posted 3 years ago #

    Hi Steve,

    The code you have (from Wordbook) currently does this. It converts:

    <wpg2>2296</wpg2>

    to:

    http://will.sitch.org/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=2296

    The problem is that the fb stream attachment, when set to attach "image" media, doesn't seem to want to accept the GET content of the URL. At least, that's what I think is happening. I can't read what FB accepted and there's no error code thrown.

    Ideas? I'm fresh out.

    Will

  9. Steve
    Member
    Plugin Author

    Posted 3 years ago #

    So what we need to do is work out what the file is associated with 2296 and then put that URL into the image array rather than the wpg2 download path.

    Then we have to change my tag stripping code to get rid of the content of the wpg2 tag in the FB post....of course it doesn't help that my installation of WP strips out the WPG2 tags when I save the post (I've not actually installed either WPG2 or the main gallery app)

  10. wsitch
    Member
    Posted 3 years ago #

    Okay I wrote some .htaccess rules to map:

    http://will.sitch.org/gallery2/view/2296

    to:

    http://will.sitch.org/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=2296&g2_serialNumber=2

    The .htaccess doesn't rewrite the URL the browser thinks it's viewing, so it seems pretty foolproof. I tried adding the following code to your strip_images function but it didn't work:

    if (stripos($var['src'],'main.php?g2_view=core.DownloadItem&g2_itemId='))
        {
            $var['src'] = str_ireplace("main.php?g2_view=core.DownloadItem&g2_itemId=","view/");
            $var['src'] = str_ireplace("&g2_serialNumber=1","");
        }

    This seems like a total hack. Are you sure the facebook stream attachment is really ignoring the GET elements of the URL for the image media? That seems wack.

    Thanks for all your help.

    Will

  11. Steve
    Member
    Plugin Author

    Posted 3 years ago #

    I don't know - if I get some time this weekend I'll do some asking around.

    .htaccess rules would be a complete pain because it would be different on each installation.

  12. Steve
    Member
    Plugin Author

    Posted 3 years ago #

    It should work according to someone on the FB Developers forum.... but from other posts I've seen FB is having image handling problems again....

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags