If the user uploads an image in the imagefield directly then the uploaded image should take precedent and there shouldn't be a PDF-based image generated at all.
Inserting these lines inside the pdf_to_image_generate_process function around line 370 (right after the comment that says "// Should I check if the target field is already populated and stop then?" in pdf_to_image.module
// Don't generate a new image if the PDF file didn't change.
if ($entity->{$field_id}['und'][0]['fid'] == $entity->original->{$field_id}['und'][0]['fid'] ) {
return;
}
// Don't generate an image if new node and the imagefield has image uploaded in it.
if ((!$entity->original) && ($entity->{$target_field}['und'][0]['fid'])) {
return;
}
I'll roll this as a patch and attach to a followup comment.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | pdf_to_imagefield-allow-image-uploaded-2049725-4.patch | 1.7 KB | dman |
| #1 | pdf_to_imagefield-uploaded_supersedes_generated_image-2049725-1.patch | 1.09 KB | artis |
Comments
Comment #1
artis commentedComment #2
dman commentedYes, that was the intended behavior from the start. I thought it used to do that.
If that logic has been lost during some of the logical refactoring over time, it's good to get it back again!!!
Comment #3
dman commentedI tested it by uploading a manual image over an existing doc page, and also from new.
Seems to do what it says BUT I'm getting
Code that uses [und] etc is always at risk of introducing problems like this. (Not because of [und], but it's a sign we are not using the full API correctly)
See http://www.davereid.net/content/hlkd7fotw-field-get-items about how to use field_get_items()
.. I'll sort that out..
Comment #4
dman commentedHere is a remake of that logic.
Note, it's significantly different. Uses the API to file the existing fids, and treats the 'new' node and the 'updated' node as exclusive possibilities.
Basically a full rewrite.
Comment #6
hitchshockWe stopped supporting the D7 version, so the ticket will be closed, but thanks to everyone who was working on the ticket!