Drupal (CMS): How do I write PHP to output the path an image from a CCK imagefield?
-
Here is my specific situation: My nodes have a CCK imagefield. Hence, each node will have a different image uploaded. I would like to 'raw' output that URL path of the image using PHP. I need this path for Facebook's OpenGraph meta tags (http://developers.facebook.com/docs/opengraph/). For example: <meta property="og:image" content="<?php OUTPUT IMAGE PATH HERE ?>"/>
-
Answer:
To get the path of the image [AND the facebook markup] to show on the NODE page do the following: Modules needed: viewfield views 1] Create a new view and name it Facebook-Meta [only a default will be created. NO block or Page etc]] Set an argument for NID that is set to default to the NID from the URL. Add a field for the image and set the display format to IMAGE PATH & rewrite the output of the field. In the text field provided enter the Facebook markup and use the TOKEN provided that plugs the image path into the rewrite text. 2] Go to the MANAGE FIELDS of your content type and add a new field labeled Facebook-Meta and select the VIEWFIELD as its type. From the list provided choose the Facebook-Meta view from the list towards the bottom. In the ARGUMENT field at the bottom add these 4 characters %nid That should do it. You may need to tweek the textfield of the REWRITE output to get facebook totally happy with your syntax. Let me know how this goes for you! :-) - Doug Vann [Drupal Trainer , Consultant , Developer] - http://dougvann.com
Doug Vann at Quora Visit the source
Related Q & A:
- How do I write a good peer review?Best solution by Quora
- How do I write a search page?Best solution by Stack Overflow
- How can I write a good reference letter?Best solution by dailywritingtips.com
- How do I write a Photography Price Quote?Best solution by Yahoo! Answers
- How do I write a resume for a part-time job?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.