Gallery2:How To Use The External Image Block When url fopen Is Disabled - Gallery Codex
Personal tools

Gallery2:How To Use The External Image Block When url fopen Is Disabled

From Gallery Codex

Some webhosts disable PHP url_fopen for security purposes. That's not a bad idea. But then you'll have to use the following code snippet instead of readfile().

User personman from the forums wrote this small code snippet. Requirement is libcurl. So it might or might not work on your webserver, depending on this requirement.

<?php
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://www.example.com/gallery/main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=title');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
?>

Replace

http://www.example.com/gallery/main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=title

with your own external image block URL which can be found in Site admin -> Image Block

See: http://galleryproject.org/node/36604#comment-133000