I created a image field and want to place it not in the content area. I want to place it after opening tag and output only the path to the image file.

I need following HTML/CSS markup:

<div class="headerimage" style="background-image: url(image-file.jpg);"></div>

I read some tutorials but not all works or are secure.

Comments

jalpesh’s picture

Why don't you create .tpl file for the content type in which you want to display image field????

To create a .tpl file you have to create a file with name node--content-type-machine-name.tpl.php. Write your HTML code in this file and save this file in you active theme.

alexander.sibert’s picture

Yes, you are right but how i can output simple a specific field via PHP in Drupal 7? At the moment it is in the content area. For example you see it here http://neofelis.de/drupal-commerce

Catopuma - Internet-agency for Webdevelopment and Internet-Marketing
Visit us on http://catopuma.com

jalpesh’s picture

can you please explain little bit more??

alexander.sibert’s picture

I have created a image field in Drupal where i want to upload the header images. That is ok but now it will displayed in the content area and i need it after the opening tag because i want it as responsive background image. For example what i mean visit http://www.skype.de.

I tried this hardcoded with the page.tpl.php but it works not.

Catopuma - Internet-agency for Webdevelopment and Internet-Marketing
Visit us on http://catopuma.com

jalpesh’s picture

I am looking at http://neofelis.de/en/drupal-commerce and the image which you have uploaded in content that is display in content area but you need this image above the "Drupal Commerce" title right?

I have following question.
1) Are you uploading image in content?? Did you created upload image field in content type??
2) After which tag you need to display image??
3) The tag after which you need to display is in Content area or in header??
4) Please give me the list of fields which you are using in your content type??

Please answer the above questions so my all dough are clear.

alexander.sibert’s picture

1. I created a image field for the node type and uploaded the image.
2. The best is to output this field before the title and content. Then can i can put this image with full width in the header area via CSS.
3. The best will be before the header. I can put my navigation layer over the image.
4. the list of current fields.

  1. Image field_page_image Media file selector
  2. title
  3. body
  4. Language
  5. URL-Alias-settings
  6. XML sitemap
  7. URL-redirects
  8. Meta-Tags

To use the headerimage module is for me to overhead.

Catopuma - Internet-agency for Webdevelopment and Internet-Marketing
Visit us on http://catopuma.com

alexander.sibert’s picture

I have thought about the solution. I make it now easily with views module. I create a template region and create a views block, that's it.

Catopuma - Internet-agency for Webdevelopment and Internet-Marketing
Visit us on http://catopuma.com

jalpesh’s picture

I think it is also possible with .tpl file which i suggest you but i don't know the what is the problem you are facing with .tpl file. OK leave it, it's good to see that you found a solution.

alexander.sibert’s picture

Yep :). Thank you for your support.

Catopuma - Internet-agency for Webdevelopment and Internet-Marketing
Visit us on http://catopuma.com