Jump to content

Help with background image URL pointing to PHP Script. .


hchage

Recommended Posts

Hi everyone,

 

So here's what I'm trying to do: I have a page that a background image in a region with the CSS tag:

 

.image_rotator_album { background-image: url('flowers01.jpg') no-repeat; }

 

I've also got a gallery2 installation running at the same time, and can pull up an image from within the gallery using one of the functions built into the program (main.php), using the following code:

 

http://whisper.datafiregroup.com/static/yard01/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=346&g2_serialNumber=4 

 

What I'd like to do is have the background-image be set by using a PHP script. . something like this:

 

.image_rotator_album { background-image: url('http://whisper.datafiregroup.com/static/yard01/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=346&g2_serialNumber=4') no-repeat;

 

But for whatever reason, that doesn't work. . so my question is - is it possible for the CSS background-image URL property to be set to a PHP function, and if so, does anyone have any idea why the code I provided doesn't work?

 

I've checked the header information for the link that I've provided, and it does appear to show the correct content-type:

(using http://seopen.com/seopen-tools/header-checker.php and the URL provided above)

 

Response Code: HTTP/1.1 200

Date: Wed, 11 Mar 2009 21:46:44 GMT

Server: Apache/2.2.10 (Unix) mod_ssl/2.2.10 OpenSSL/0.9.8i DAV/2 PHP/5.2.8 proxy_html/3.0.1

X-Powered-By: PHP/5.2.8

Expires: Tue, 19 Jan 2038 03:14:07 GMT

Content-Type: image/jpeg

Last-Modified: Tue, 10 Mar 2009 20:01:19 GMT

Cache-Control: public

 

Link to comment
Share on other sites

When I try a simple test on my local box, it works. But not when using your image at http://whisper.datafiregroup.com/static/yard01/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=346&g2_serialNumber=4 (even when correcting the & mistake). But when I use some random online PHP image I found, it works again. Could it be your image script blocking out external usage? That's my only guess.

Link to comment
Share on other sites

Thanks for the attempt. . maybe we're getting a bit closer to the root of the problem. . .

 

I've created a separate PHP file that essentially grabs the image in the first URL, applies header data to it, then spits that back out. This PHP file is located at http://whisper.datafiregroup.com/static/yard01/portfolio/return_image.php and includes:

 

<?php
$imagedata = file_get_contents('http://whisper.datafiregroup.com/static/yard01/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=346&g2_serialNumber=4');
header('Content-Type: image/jpeg');
header('Content-Length: '.strlen($imagedata));
echo $imagedata;
?> 

 

Theoretically (and according to the post here : http://www.howtocreate.co.uk/emails/AndrewThomasBlake.html ) this should allow me to set the background image using the following:

 

.image_rotator_album { background: url('http://whisper.datafiregroup.com/static/yard01/portfolio/return_image.php') }

 

But no dice. .

 

Is there a different way to recompile an image so its headers can be properly read?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.