views:

71

answers:

2

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 */
+1  A: 

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
+1 for both general approaches.
cballou
Thank you so much! I'm developing this as part of a WordPress theme and I'd like to use the WordPress function <?php bloginfo('template_directory') ?>Do you know how I could substitute $rel_path with bloginfo('template_directory')?
Brian
Thanks! Still have some things to work out, but this works!
Brian
A: 

Doesn't work for me. Putting above the html tag does not let me assign it to the variable $rel_path. It simply runs where I initially put bloginfo('template_directory');

Jon