0

I'm trying to insert a relative URL in the code below before "/images" in $thumb_directory and $orig_directory however I'm not sure how to do so within 'apostrophe's'. Also, this is a WordPress website, so if anyone knows how to call the function within '/images', like so: '/images' please let me know (I realize that what I just typed is incorrect syntax).

<?php
/* Configuration Start */
$thumb_directory = '/images';
$orig_directory = '/images';
$stage_width=600;
$stage_height=400;
/* Configuration end */
Brian
  • 3,920
  • 12
  • 55
  • 100

1 Answers1

1

Assuming that the relative path is in the variable $rel_path, use double quotes:

$thumb_directory = "$rel_path/images";
$orig_directory = "$rel_path/images";

With double quotes variables (starting with $) are replaced by their value, but this doesn't happen with single quotes.

Or use string concatenation:

$thumb_directory = $rel_path . '/images';
$orig_directory = $rel_path . '/images';

EDIT

If your relative path comes from bloginfo('template_directory'), simply add the following line before using $rel_path (so before the lines above):

$rel_path = bloginfo('template_directory');

This sets the variable with the path you want. Ensure all these lines are within the PHP processing tags <?php and ?>, and don't forget the semicolon ; at the end of the assignment line ;-)

catchmeifyoutry
  • 7,179
  • 1
  • 29
  • 26
  • Thank you so much! I'm developing this as part of a WordPress theme and I'd like to use the WordPress function Do you know how I could substitute $rel_path with bloginfo('template_directory')? – Brian Dec 09 '09 at 18:57