Jump to:
| Project: | ImageField |
| Version: | 6.x-3.0 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I have a CCK rich text field with an image in it. What I'm trying to do is extract the image of this text field and put it into a CCK ImageField field.
For this I use a computed field :
Computed code :
<?php
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $node->field_clickimage[0]['value'], $matches);
$node_field[0]['value'] = $matches [1] [0];
?>where field_clickimage is the rich text cck field.
Display format :
<?php
$display = '<img src="' . $node_field_item['value'] . '" alt="' . $node->title . '">';
?>as described in http://drupal.org/node/1045712#comment-4300894 .
This works, it extracts the image from the text and displays it in the computed field. But what I would like to do now is to put this image file in an ImageField field.
The reason for this whole issue is that I want to avoid users uploading twice the same image, first to display in the text, and second to create the thumbnail of the node.
I followed advice from there
https://drupal.org/node/991586
and it gives me a filesize() error on line 156. Maybe because I'm in private download mode?
Any help welcome!
Comments
#1
I do not provide support on custom coding in my module issue queues. I'll leave this open for a while for others to answer.
#2
Thanks. I will just post my solution here as well in case other people have the same problem :
I was trying to take the inline image and save it in an image field. But I just found out about the Insert module. It seems a much easier and future proof solution than using IMCE to upload the file into the textfield, and then a computed field to put it into the imagefield, to be used with imagecache. Just installed Insert module and it is PERFECT! And works with Views also! And I'm switching back the filesystem to public (had to put it in private because with IMCE, users could see each others' folders by default). So a much leaner website also.
So after spending almost a week trying to make things work with a custom module or a computed field, I stumbled upon mustarseed's podcast on Filefield Insert, totally by chance (I was looking for a way to get the fid of IMCE uploaded images). Whew!
#3
Maybe I ask something not on this topic...so, is there a way to add through the "ImageField extended" module to add a new type of field? Through the module I can add only textarea, textfield, checkbox or radiobutton types of field,but I need to add an Upload FileField to the image. I want to do this becouse I need to create a photo gallery where I put the Image, Title of image, Short Description, Long Description and a file whish is attached to the image (this could be an pdf, txt, doc etc.). So, users will have posibility to download the file attached to the image. Someone can help me ? Thanks.
Andrew