Remove Link from Image Attach in Drupal
Mar
1
2010
UPDATE: Note, the code below may be out of date or not work with the newest version of image attach.
If you are using the Image Attach module in Drupal, you may not always want to have the image linked. Drupal links the image automatically to its own image node but sometimes you don't want that.
You can add an overide to your theme's template.php file. Note where it says 'your_theme' on line one, replace that with the name if your actual theme. You should also clear your Drupal cache after adding this code.
- function your_theme_image_attach_body($node, $iid) {
- $img_size = variable_get('image_attach_size_body_'. $node->type, IMAGE_THUMBNAIL);
- if ($img_size != IMAGE_ATTACH_HIDDEN) {
- drupal_add_css(drupal_get_path('module', 'image_attach') .'/image_attach.css');
- $image = node_load($iid);
- if (!node_access('view', $image)) {
- // If the image is restricted, don't show it as an attachment.
- return NULL;
- }
- $class = 'image-attach-body' . ($image->status ? '' : ' image-unpublished');
- $info = image_get_info(file_create_path($image->images[$img_size]));
- $output = '
- </p><div class="' . $class . '">';
- $output .= image_display($image, $img_size);
- $output .= '</div><p>'."\n";
- return $output;
- }
- }


Great contribution
Thanks a lot, just what I was looking for.
This should be in drupal.org
Great contribution
Thanks a lot
Regards
W.Wallace
Fine
Thanks a lot! You are great.
This is the right one i`ve be searching a long time on the web.
It`s easy to implement and works fine.
Best regards from munich!
Axel
Thanks a lot, just what I was
Thanks a lot, just what I was looking for.
This should be in drupal.org
Thanks for pointing out that function
That helped a lot. I had not found that function before but needed to get rid of the css that this function is adding to the HTML code:
Now, it's easy. And I agree with the previous commentator, that this should be somehow explained on drupal.org as part of the image attach functionality.
That was cool hack. I am not
That was cool hack. I am not a good programmer specially can't play with Drupal but give my most time to Wordpress. This image attach module was giving a lot pain in my a** :). Every image were being attached which should have been disabled to save. Anyway, now I can move to search for new hack to disable saving image from my website.
Facebook Application Analytics
On the Theming side...
This script works unless you're using the latest version of image-attach. I believe they updated some things. Correct me if I'm wrong.
Here's a way to get just the image source using regex on the theme side:
This will print the image url instead of all that other slop.
Thanks for the code and
Thanks for the code and comment, I now favor using CCK fields for images in combo with imagecache, I find that combo works better and it tends not clutter things up as image nodes are no longer being created. CCK images also work better if you ever want to render that stuff in any kind of view. cheers!
Duly Noted
Interesting. Thanks for the reply.
This works with the latest version of image_attach in D6