1

I have some image links that are inside standard <a href> tags, that link to some external sites. Example: <a href="http://http://www.webbdeepsky.com/" title="The Webb Deep Sky Society" target="_blank"><img class="supporter-logo" src="assets/images/webds.png" alt="Bedford Astronomical Society - Supporters of The Webb Deep Sky Society"></a>

The images display no problem, until I go to add a node of my custom content type "Front Page Announcement". Then, the images do not display - i.e. the path to the image cannot be found.

I URL I get is: http://localhost/bedsastro_new/node/add/front-page-announcement And the images are in assets/site-images/

When I look at at where the browser is expecting the image to be, it's : http://localhost/bedsastro_new/node/add/front-page-annoucement/assets/site-images/pic.jpg

How do I ensure that Drupal is looking at right location for the images (i.e. http://localhost/bedsastro_new/assets/site-images/pic.jpg) ?

Thanks! Daz

  • Your img src needs to be /assets/images/webds.png – Patrick Ryan Jun 21 '15 at 19:20
0

It seems that the root of your Drupal site is http://localhost/bedsastro_new/ .

To reference an image with filename pic.jpg (using an img tag) which is located in the site's subfolder named assets/site-images, you should specify /assets/site-images/pic.jpg as the value of the src attribute within the img tag.

With that, Drupal will try to find that image at http://localhost/bedsastro_new/assets/site-images/pic.jpg, which is where your image is actually located, so that should work.

| improve this answer | |
  • Oh, I can't believe I missed that!! Thank you Pierre, for spotting my mistake! I am still learning Drupal and I figured I had done (or not done) something in a setting somwehere!! – AstroDaz Jun 21 '15 at 20:22
  • Except..... having changed the img src path to include the backslash, now the images on ANY page do not show.... The path for the images is now http://localost/assets/site-images/ - the bedsastro_new part of the path has been removed from all the img tags – AstroDaz Jun 21 '15 at 20:28
  • I'm not sure I understand HOW you changed the "img src". What is the purpose of this pic.jpg? What is the purpose of those image links? If you change that link in 1 specific node, how can that be related to "now the images on ANY page do not show"? Also, in your .htaccess file, what have you specified for the line continaing "RewriteBase" (typically around line 106)? – Pierre.Vriens Jun 21 '15 at 20:47
  • Hi Pierre, Yes, perhaps I'm not being clear enough.. I have a block which contains 5 small images, wrapped in <a href> tags to link to other sites. This block sits in one of the footer regions of the theme. If you look at bedsastro.org.uk it is the right-hand region of the footer. I am revising the site with a new theme. – AstroDaz Jun 22 '15 at 6:49
  • So, after your initial post, I updates the code in the block to read <a href="http://http://www.webbdeepsky.com/" title="The Webb Deep Sky Society" target="_blank"><img class="supporter-logo" src="/assets/images/webds.png" alt="Bedford Astronomical Society - Supporters of The Webb Deep Sky Society"></a> with the / in the src element. – AstroDaz Jun 22 '15 at 6:49
0

OK, I found the solution - or at least A solution!

I updated the paths for the images to use <?php print base_path(); >/asset/site-images/image.jpg

And this worked :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.