[support] URL attached to image.

Patrick Avella me at patrickavella.com
Fri Jun 15 23:50:10 UTC 2012


Hi Anthony,

I think you may be over complicating the issue a bit. If you know HTML
and a little bit of basic PHP you can accomplish this goal very easily
using a node.tpl file.

http://api.drupal.org/api/drupal/modules!node!node.tpl.php/7

After putting the node.tpl in your templates directory and clearing
Drupal's cache under configuration->performance you can now mix,
match, mash, and display all of the node content any way you like.

If your image field is called "linkedimage" for example, you can put:

<?php dpm($content['field_linkedimage']); ?>

When you view the page Drupal will show you the array structure of the
image including it's filename, location in the files folder, etc.
Using this information you can construct your own <a href> tag,
possibley basing it off of content found in other fields on the node.

To me at least, this is the easiest way to 'over ride' how drupal
renders a field. If you take a quick read through the documents you'll
see that modifying a tpl file makes a lot of things possible very
easily. The best part is that it's a popular solution, so there is
lots of help available with a google search.

I hope it helps.

(If you wanted to stay true to an MVC structure you would want to do
any variable processing in the template file, but there's no law
against quick and easy solutions!)

On Thu, Jun 14, 2012 at 6:48 PM, Anthony <tony at tony-mac.com> wrote:
> I have been exploring possibilities here.
> I created a new content type and am at the manage display screen .There I
> have a possibility, for the image field, under the format column to "link
> image to" either file, content or nothing. When I link to content or file
> and view the content type I can see that there is a link on the image but I
> don't know where to set that - hopefully url in my case.
> Thanks
> Tony
>
>
>
> On Wed, Jun 13, 2012 at 7:51 PM, Anthony <tony at tony-mac.com> wrote:
>>
>> excuse that last. Think before you write Tony.
>>
>> On Wed, Jun 13, 2012 at 7:46 PM, Anthony <tony at tony-mac.com> wrote:
>>>
>>> Won't it suffice to just use the link module?
>>>
>>>
>>> On Wed, Jun 13, 2012 at 7:20 PM, Anthony <tony at tony-mac.com> wrote:
>>>>
>>>> Thanks Jamie. I will try it out.
>>>>
>>>> On Wed, Jun 13, 2012 at 5:33 PM, Jamie Holly
>>>> <hovercrafter at earthlink.net> wrote:
>>>>>
>>>>> The easiest method would probably be to preprocess
>>>>> theme_image_formatter (D7) in your theme's template.php:
>>>>>
>>>>> function mytheme_preprocess_image_formatter($variables){
>>>>>   $variables['path'] = array(
>>>>>         'path' => '{...some path here..}',
>>>>>         'options' => '{any l() options you want passed if needed}',
>>>>>    );
>>>>> }
>>>>>
>>>>> You can also go the module route with a custom formatter, which would
>>>>> probably be the better route (you then get the ability to use it or not when
>>>>> setting your entity display):
>>>>>
>>>>>
>>>>> http://www.computerminds.co.uk/articles/creating-new-field-formatters-drupal-7
>>>>>
>>>>> Jamie Holly
>>>>> http://www.intoxination.net
>>>>> http://www.hollyit.net
>>>>>
>>>>>
>>>>> On 6/13/2012 8:20 PM, Anthony wrote:
>>>>>
>>>>> So I have to create a tpl file for the node and then ? More info or
>>>>> references, if possible, greatly appreciated.
>>>>>
>>>>> On Wed, Jun 13, 2012 at 5:08 PM, Patrick Avella <me at patrickavella.com>
>>>>> wrote:
>>>>>>
>>>>>> This can be easily done theming a node.tpl file if you dont want to
>>>>>> use a view.
>>>>>>
>>>>>> sent from my phone.
>>>>>>
>>>>>> On Jun 13, 2012 8:06 PM, "LINDA ROMEY" <lromey at gmail.com> wrote:
>>>>>>>
>>>>>>> I'm sorry but I'm not a programmer so I can't answer that
>>>>>>> question...is that something you can do with css?
>>>>>>>
>>>>>>> On Jun 13, 2012, at 5:44 PM, Anthony wrote:
>>>>>>>
>>>>>>> I don't want to change the site to use a view on that one page. When
>>>>>>> one goes to edit the image field in the content type I can "Click a token to
>>>>>>> insert it into the field you've last clicked.". But that is not what i want
>>>>>>> I think.  Can I programmatically attach a url to a mouseover event on the
>>>>>>> image?
>>>>>>>
>>>>>>> On Wed, Jun 13, 2012 at 10:55 AM, Linda Romey <lromey at gmail.com>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Tony, I use a view to display the field and use the view's "rewrite
>>>>>>>> the contents of this field" using tokens. It works very well.
>>>>>>>> Linda
>>>>>>>>
>>>>>>>> On Wed, Jun 13, 2012 at 1:22 PM, Anthony <tony at tony-mac.com> wrote:
>>>>>>>>>
>>>>>>>>> Dear All,
>>>>>>>>> I have a content type with an image field. How can I attach an "<a
>>>>>>>>> href= " tag  to an instance of this content type field?
>>>>>>>>> Thanks
>>>>>>>>> Tony
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> Anthony Stefan Maciejowski
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> Anthony Stefan Maciejowski
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>>>>
>>>>>>
>>>>>> --
>>>>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> Anthony Stefan Maciejowski
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> Anthony Stefan Maciejowski
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> Anthony Stefan Maciejowski
>>>
>>>
>>>
>>
>>
>>
>> --
>>
>> Anthony Stefan Maciejowski
>>
>>
>>
>
>
>
> --
>
> Anthony Stefan Maciejowski
>
>
>
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]


More information about the support mailing list