Remove Link from Image Attach in Drupal
Mar
1
2010
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;
-
}
-
}



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
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:
$output = '';
$output .= l(image_display($image, $img_size), "node/$iid", array('html' => TRUE));
$output .= ''."\n";
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.
Thanks a lot, just what I was
Thanks a lot, just what I was looking for.
This should be in drupal.org
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
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
Post new comment