views:

35

answers:

2

I'm sure this is simple, but I'm not able to figure out why this is not working.

If I use the first imagegif function, it works perfectly. However, when I comment that one out and try to use the second one, it fails. No error, it just does not write the image file.

    imagegif($img, "../wp-content/themes/mytheme/styles/test/sidebar.gif");
    imagegif($img, get_bloginfo('template_directory')."/styles/test/sidebar.gif");

This function is located in my functions.php file located in my theme directory, which is why in the hardcoded imagegif function, I'm moving the directory up one level.

Perhaps the imagegif function needs a relative path and not absolute? If so, how to convert the get_bloginfo to a relative path?

A: 

var_dump(get_bloginfo('template_directory')) and see what it says; my guess would be it's not the path you're expecting.

Steve
@Steve, thanks for the input, but I'm using get_bloginfo('template_directory') in lots of places in the functions.php file and its working fine. I believe the issue is that imagegif must be a RELATIVE path.
Scott B
That leaves me with two options: convert the path to relative if a built in function exists to do so, or use regex on the get_bloginfo value to convert it to a relative path.
Scott B
Try using the constant `TEMPLATEPATH`, many examples on Google lead to that returning a different value to `get_bloginfo('template_directory')`.
Steve
@Steve - I use TEMPLATEPATH when loading or including files. However, it returns an ABSOLUTE path, not relative. I believe the imagegif function MUST be fed a relative path.
Scott B
A: 

TEMPLATEPATH

This returns the path to the template files of a theme. If a child theme is activated, this path will still point to the parent theme. An example path would be “/var/www/html/mysite/wp-content/themes/parenttheme”. You would most likely use this call to include a file. Example code in the functions.php file:

// Create Theme Options Page
require_once(TEMPLATEPATH . '/extensions/theme-options.php');

bloginfo(‘template_directory’);

bloginfo(‘template_directory’) returns the URL of the template directory. An example of this would be “http://mysite.com/multisite1/wp-content/themes/parenttheme”. This could be used to call a stylesheet or an image file. If a child theme is activated, this still returns the parent template directory. Example code in the header.php file:

<!--[if IE 6]>
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('template_directory'); ?>/css/ie6.css" />
<![endif]-->

Taken from Wordpress Theming: Where’s My Theme File?

Steve