melting_dog Posted November 19, 2011 Share Posted November 19, 2011 Hi guys - a bit of a wierd one - I have installed a plugin that allows me to run PHP from a WP post or page - but I am having difficulty (probably with the syntax) when echoing an image. I know I must use the bloginfo("template_directory") but I am not sure how to include it in an echo - especially drawing the image path form a DB row.. eg: echo '<img src="' . bloginfo("template_directory") . $row['itemimage'] . '"/>'; In this form, the template directory path is simple printed to the screen as a string - the image itself fails to appear. I simply cannot get this to work. Can any one help me out? Sorry if this is unclear. Thanks heaps again! Quote Link to comment Share on other sites More sharing options...
sunfighter Posted November 19, 2011 Share Posted November 19, 2011 I have no way of knowing what bloginfo("template_directory") will translate to. So let's use images as the place where my images are stored. To echo out a stored image using $row["itemimage"] = '1.jpg'; I'd use this code: echo "<img src=\"images/".$row['itemimage']."\" />"; So substituting the bloginfo("template_directory") gives: echo "<img src=\"bloginfo(\"template_directory\")".$row['itemimage']."\" />"; If that does not work you may need to add a / to bloginfo(\"template_directory\") as I have done with images. A good way to check what you have is to write a php script with echo "<img src=\"bloginfo(\"template_directory\")".$row['itemimage']."\" />"; As the only line. Then open it in your browser and view the page source to see what is missing. Quote Link to comment Share on other sites More sharing options...
melting_dog Posted November 29, 2011 Author Share Posted November 29, 2011 Allright - un update on this, sorry for the delay - was away overseas. I decided to just past the entire first part of the path in to see what happens: echo '<img src="http://localhost/xampp/website/uploads/'. $row['itemimage'] . '"/>'; Still got no image, so I opened up firebug. I see the complete image path in the code there that should be working, but with a little message saying it failed to load the image. I copied the entire path into my browser and got a 403 error: Access forbidden! New XAMPP security concept: Access to the requested object is only available from the local network. This setting can be configured in the file "httpd-xampp.conf". Is this something to do with XAMPP? I tried googling it and couldnt find anything to that helped. Can someone point me in the right direction? Thanks! Quote Link to comment Share on other sites More sharing options...
trq Posted November 29, 2011 Share Posted November 29, 2011 Have you tried looking in the httpd-xampp.conf file? Xampp sux balls because it teaches people to be lazy and not bother actually learning how things work / should be configured. Apache HTTP is the server underneath. Anyway, there is likely an access restriction preventing access from outside of the local network. Still though, localhost can actually only ever resolve to the local machine so.... Still, this might be of some use: http://httpd.apache.org/docs/2.0/mod/mod_access.html#allow Quote Link to comment Share on other sites More sharing options...
melting_dog Posted November 29, 2011 Author Share Posted November 29, 2011 Hi Thorpe - yes I have looked at the xxamp file. I googled a fix on the 403 error and most sites recommend I change the line 'Allow from localhost' to 'Allow from 127.0.0.1' I tried to find the line but my file has this instead: <LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))"> Order deny,allow Deny from all Allow from ::1 127.0.0.0/8 \ fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 \ fe80::/10 169.254.0.0/16 ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var </LocationMatch> Would you know how I could modify this to help? Cheers Quote Link to comment Share on other sites More sharing options...
melting_dog Posted December 4, 2011 Author Share Posted December 4, 2011 OK this has been solved. The issue was that my WP site was living in htdocs/xampp rather then just htdocs. Also the file permissions on the images where all wrong and blocking the server Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.