This topic is locked

Create Image Link

6/18/2007 7:34:28 AM
PHPRunner General questions
G
Gidget author

My product images are in a separate directory and not in the database. Each image name corresponds to the product id field in the database. For example, where the product id is "123456" the image name is 123456.jpg.
How would I create a field to display the image?
Thanks much for any help.

J
Jane 6/18/2007

Hi,
you can do the following:

  • create new varchar field in the database. Image name will be stored in this field.
  • set up this field as File on the "View as" settings and "Edit as" settings dialogs on the Visual Editor tab.

G
Gidget author 6/18/2007

Thanks for the response, but it soared completely over my head.
When you say create a database field, do you mean an empty one? That I then populate somehow?
There is no editing or upload function in this app, and I don't think I even need a field in the db. The images already exist and simply sit in an image directory.
I need to build a field that references them - {product_id}.jpg by looking at the product_id field, getting the value, and creating the link.
Shouldn't there be a way I can just build this on the fly?

G
Gidget author 6/18/2007

Ok, I've been doing my homework...and I think where I need to go is roughly here
$row = mysql_fetch_array($query);

echo '<img src"./img/'.$row['id'].'.jpg" alt="image" /> ';
Where and how do I implement something like that in PHPRunner? and does anybody know if that is fairly close?

Alexey admin 6/19/2007

Hi,
here is what you can do.

Open List page on the Visual Editor tab.

Double-click ID field and choose Custom.

Put this code into the box:

$value='<img src"./img/'.$value.'.jpg" alt="image" /> ';

G
Gidget author 6/20/2007

Thank you so much!! I appreciate the help.

G
Gidget author 6/22/2007

I'm almost there but not quite!! I added the variable to my id field, and that is where the image appears. I need to get the id field back - do I just add another id field?
Also, the type for this field is now custom, so I can't use any of the image functions. How do I generate thumbnails?
Thanks.

Sergey Kornilov admin 6/23/2007

Thumbnails are generated when image is uploaded. It's not related to custom view type.
If you need ID field to appear twice use alias in SQL query:

select ID,

ID as ID1,

...

from ...