@readfile in external image block

Continental

Joined: 2004-06-14
Posts: 243
Posted: Mon, 2005-12-05 20:30

So, I ran my g2 on dreamhost and I can't show up Image Block. I see nothing. Under Drupal see error. The reason is because Dreamhost doesn't allow make @readfile function and load images from external places. There is a document on Dreamhost knowledge base (but now i can't find it again) thatn describes how to use "include" without external path. But there is not a word about readfile and I really don't know how to make this external PHP block work even in my internal SERVER along with only one path.


Gallery version = 2.0.2 core 1.0.0.2
Drupal: 4.6.3
PHP version = 4.3.10 cgi
Webserver = Apache/1.3.33 (Unix) DAV/1.0.3 mod_fastcgi/2.4.2 mod_gzip/1.3.26.1a PHP/4.3.10 mod_ssl/2.8.22 OpenSSL/0.9.7e
Database = mysql 4.1.14-Debian_5-log
Toolkits = Exif, ImageMagick, NetPBM, Gd, Thumbnail, ArchiveUpload, SquareThumb
Operating system = Linux flower 2.4.29-grsec+w+fhs6b+gr0501+nfs+a32+++p4+sata+c4+gr2b-v6.189 #1 SMP Mon Feb 7 13:23:30 PST 2005 i686
Browser = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Mailinfo [103985]; SV1; .NET CLR 1.1.4322)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-12-05 22:07
 
Continental

Joined: 2004-06-14
Posts: 243
Posted: Tue, 2005-12-06 09:49

[/b]thx. embarrased that's I looked so hard and that was so easy and the answer near. It works perfectly, but since my G2 is embed in Drupal I found interesting the next artice:
http://codex.gallery2.org/index.php/Gallery2:GalleryEmbed:getImageBlock

1/
when I put this code directly (changing only paths from /gallery2/ to /gallery_standalon_real_path/ or /gallery_embed_unreal_path_under_druapl/) I have an error:

Quote:
<size=9]
warning: Unknown(/my_serves_path/includes/my_gallery_path/embed.php): failed to open stream: No such file or directory in /my_server_path/includes/common.inc(1816) : eval()'d code on line 3.
Fatal error: (null)(): Failed opening required '/my_server_path/includes/my_gallery_path/embed.php' (include_path='.:/usr/local/lib/php') in /my_server_path/includes/common.inc(1816) : eval()'d code on line 3
[/size]

So, I change the line

Quote:
require_once(dirname(__FILE__) . '/my_gallery_path/embed.php');
for
require_once('/my_server_path/my_gallery_path/embed.php');

Then,
If /gallery2/ dir = /gallery_standalon_real_path/ (both in two lines)
it show thumbnail, but the link is http://www.server.ru/gallery_standalon_real_path/gallery/countries/sweden/Sweden_CafeGrassTree.jpg.html

If /gallery2/ dir = /gallery_embed_unreal_path_under_drupal/ (only in the second line)
it show thumbnail, but the link is http://www.server.ru/gallery_embed_unreal_path_under_drupal/gallery/countries/sweden/Sweden_CafeGrassTree.jpg.html
(it goes /gallery/gallery twice!)
If the code is like

Quote:
require_once('my_server_path/my_real_gallery_path/embed.php');
$ret = GalleryEmbed::init(array('fullInit' => true, 'embedPath' => '/'));

the link is OK, but I don't see thumbnail.

No more variants. ;-) What can I do?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-12-06 13:38

since your g2 is embedded in drupal, you should use the normal drupal/g2 imageblock. that's a feature of the drupal integration.

moving the topic to the integrations forum.

 
Continental

Joined: 2004-06-14
Posts: 243
Posted: Tue, 2005-12-06 18:07

ok. gallery.module isn't enought functionality right now for me, because I shall distibute many image blocks over the site along the context e.t.c. I need to use flexible code with as many option as php-string for external image block has. It it much difference between you offered me first and that I have problems last post, and can you advice any on my last post about paths?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-12-06 18:31

you should use GalleryEmbed::getImageblock and not the readfile approach.
http://codex.gallery2.org/index.php/Gallery2:GalleryEmbed:getImageBlock

you can use http://codex.gallery2.org/index.php/Gallery2:GalleryEmbed:getImageBlock only if Gallery is installed on the same server.

$ret = GalleryEmbed::init(array('fullInit' => true, 'embedPath' => '/'));

well, also specify embedUri and relativeG2Path.

see
docs/EMBEDDING for examples.

 
Continental

Joined: 2004-06-14
Posts: 243
Posted: Tue, 2005-12-06 19:29

seem to be working, thx.

 
dagman44

Joined: 2004-03-04
Posts: 10
Posted: Mon, 2005-12-12 14:32

Valiant,
The code from the other thread works great.
A question though is in showing multiple thumbs using the "|" seperator the images align in a vertical orientation.
Is it possible to get the alignment into a Horizontal array by adding some code?

Quote:
<?php
/* You'll have to change the /gallery2/ thing in the following 2 lines probably */
require_once(dirname(__FILE__) . '/gallery2/embed.php');
$ret = GalleryEmbed::init(array('fullInit' => true, 'embedPath' => '/gallery2/'));
if ($ret->isError()) {
print 'GalleryEmbed::init failed, here is the error message: ' . $ret->getAsHtml();
exit;
}
/*
* See "Site admin" -> "image block" for all available options. the parameters are the same
* as for the external imageblock
*/
list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'randomImage',
'show' => 'title|date'));
if ($ret->isError()) {
print 'GalleryEmbed::getImageBlock failed, here is the error message: ' . $ret->getAsHtml();
exit;
}
/* $bodyHtml contains the image block. print it somewhere on your website */
print $bodyHtml;
/*
* $headHtml is not required. if you use imageframes for your imageblocks, you need to print
* $headHtml in the <head> section of your web page
*/
?>

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-12-12 17:09

@horizontal instead of verticle:
i guess you could achieve that with css. don't ask me how.

 
airsoftpacific

Joined: 2006-07-07
Posts: 5
Posted: Thu, 2006-09-14 14:43

Sorry to necropost, the search function on the site is down and this seems to be the only thread I can dig up for details on this.

I'm trying to use the libcurl code from
http://codex.gallery2.org/index.php/Gallery2:How_To_Use_The_External_Image_Block_When_url_fopen_Is_Disabled

But for some reason I am getting duplicate images when I output RecentImages, it'll show 2 of each image with the same ID. It was working fine back when I was on a host that allowed fopen commands. Has this happened to anybody else? Should I dump this idea and go with the GalleryEmbed option here http://codex.gallery2.org/index.php/Gallery2:GalleryEmbed:getImageBlock Or is this an easy fix?