Emthumb had a bunch of bugs and was in an in-between state between D5 and D6. The attached patch improves the behavior of the UI, cleans up the code a bit, and fixes these bugs:
#601466: Thumbnails doesn't work CUSTOM THUMBS NOT OVERWRITING DEFAULT
#619354: emthumb_emfield_field_extra cannot possibly work with multiple videos
#377744: Respect emthumb setting when configuring fields
#437118: Cannot disable custom thumbnail for field
maybe more...

CommentFileSizeAuthor
#18 638758v3.patch14.29 KBandrewlevine
fix_emthumb.patch15.79 KBandrewlevine

Comments

andrewlevine’s picture

Status: Active » Needs review
jjesus’s picture

I don't think it's quite working.

My source file is named jj.jpg
I specified the Image path setting for the Embedded Custom Thumbnail section of the CCK field to thumbs.

After I press the upload button, my file appears in files/thumbs/jj.jpg and it's thumbnail is displayed.

After I submit my node, I edit it and my thumbnail is no longer displayed.

I looked in the database table files and the entry is files/thumbs/jj.jpg seems correct.

I looked in the database table for my content type and found my entry. For the field_embedded_video_url_data column of my entry:

"emthumb";a:2:{s:11:"emthumb_alt";s:6:"jj.jpg";s:13:"emthumb_title";s:6:"jj.jpg";}

I think the module isn't putting the path together correctly.

jjesus’s picture

If I try the procedure of #601466: Thumbnails doesn't work CUSTOM THUMBS NOT OVERWRITING DEFAULT (submit without hitting upload), my CCK entry gets a better value for the thumbnail and when I edit the node, I can see my thumbnail.

"emthumb_alt";s:6:"jj.jpg";s:13:"emthumb_title";s:6:"jj.jpg";
s:8:"filename";s:6:"jj.jpg";s:8:"filepath";s:32:"sites/wwcdev/files/thumbs/jj.jpg";
s:8:"filemime";s:10:"image/jpeg";s:8:"filesize";i:345692;s:3:"fid";s:2:"15";}
andrewlevine’s picture

I didn't test with the image path field setting. Will do that ASAP

andrewlevine’s picture

jjesus, I was unable to reproduce your error. Are you sure you applied the patch correctly?

jjesus’s picture

Yes, I applied patch correctly.

The key is the upload button. If you hit it, emthumb will be broken. But, if you browse to the file and submit, everything is OK.

I used CSS to hide the button for now.

andrewlevine’s picture

jjesus, I can't reproduce the error, so I'm not sure what to say. The upload button didn't work in the unpatched latest version of emthumb and should work in the patched version. Could you debug the code and figure out where it is breaking? Or give me access to a drupal installation where this problem is occurring? Thanks for helping

alex ua’s picture

Status: Needs review » Needs work

I tested this out and it still needs some work. First of all, I couldn't get the emthumb form to show at all unless I changed the first two arguments (removed the reference) of emthumb_emfield_widget_extra():

i.e.

function emthumb_emfield_widget_extra(&$form, &$form_state, $field, $items, $delta = 0, $module) 

changed to

function emthumb_emfield_widget_extra($form, $form_state, $field, $items, $delta = 0, $module) 

However, even after I made that change the module still isn't working. At the moment here's what happens. I can upload an image and it shows up on the node edit form as expected. But- if I save the node the old stored thumbnail remains, even though the custom thumbnail is in fact uploaded to the correct folder. I don't have time to look into this further, but I think this is close.

Thanks for your work on this!

alex ua’s picture

I can confirm that Aaron's workaround from here works:
#601466: Thumbnails doesn't work CUSTOM THUMBS NOT OVERWRITING DEFAULT
That is to say, if I click "save" after selecting the file it works as expected. But, if I click 'upload' and then 'save' it doesn't work.

Anonymous’s picture

To #9: wait for CRON to come along, it will remove your thumbnail after a while, because the thumbs are stored with a 'temporary' file flag. Cron will wipe them. See issue #605674: Custom Thumbnail Files Disappear After a Few Hours

andrewlevine’s picture

Status: Needs work » Needs review

Alex UA and jjesus,

Not sure why you are having these problems. These are problems with emthumb before this patch is even applied but they should be solved by the patch. Are you using the dev version of emfield (6.x-1.x-dev) with the latest version of Drupal (6-14)?

I installed Drupal 6-14 from scratch with emfield/emthumb 6.x-1.x-dev, patched the module and it seemed to work fine.

Are you testing this with existing content-types/fields or making new ones? Are you using emvideo to test thumbs?

Can you try installing Drupal from scratch, creating a content type with an emthumb-enabled field and seeing if you have the same problems?

Alex UA, if you are still having problems getting the form to show with the references, can you capture a backtrace and attach it to this issue?

Thanks.

alex ua’s picture

Can you check and make sure that the patch above reflects the last changes you made to the module. I can tell you 100% that this is not working atm, even though it applies cleanly against the latest development snapshot.

If you let me know what you want a backtrace of, I'm happy to provide it.

acouch’s picture

I tried the patch as well and have the same issue in which uploaded images are not saved.

They are placed in the file system. In the emthumb_widget_element_process function the new image information is placed into the $elements variable which the function returns but are lost upon clicking submit or preview. I ran out of time on this but did notice that the 'insert' case in emthumb_emfield_field_extra is empty. Could be a culprit.

andrewlevine’s picture

Before anyone kills themselves trying to figure this out (like I did), the reason it doesn't work is a bug introduced in Drupal 6.14 #302240: button broken due to fix various problems when using form storage . I'll try to come up with a work-around for the moment, but when the 6.14 bug is fixed (or if you use it on 6.13), my original patch should work

myaussierox’s picture

I just ran the patch, ran cron and flushed the cache 3 times and the custom thumbnail stayed! Nice Job. I will keep monitoring the situation and if anything changes I will report it.

acouch’s picture

This works on my 6.14 site after this patch is applied from the thread you identified above: http://drupal.org/node/591696#comment-2097466

alex ua’s picture

Status: Needs review » Postponed

OK- I went ahead and committed this patch. I'm marking this as "Postponed" for now until the core issue is fixed.

andrewlevine’s picture

Status: Postponed » Needs review
StatusFileSize
new14.29 KB

Thanks to a suggestion by zroger and testing by robbiethegeek, I have refactored the form so that it uses a submit function on the upload button instead of tons of bizarre logic in the form function. Should make it a lot easier to understand and work on both 6.13 and 6.14.

The only catch is you need to press the upload button to upload your file before you press save. This makes sense to me given the current UI anyway, so I don't think it's a big deal.

andrewlevine’s picture

Also, this new patch is against the latest 6.x-1.x-dev (after my previous patch which was comitted)

CinemaSaville’s picture

Great job. I can confirm the new patch against the latest dev is working. Thanks so much for finally rectifying this mess.

aaron’s picture

Status: Needs review » Fixed

committed the fix. thanks for the work, andrew!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Berliner-dupe’s picture

Hello,

the Patch "fix_emthumb.patch" dont works!

I use emfield-6.x-1.18. - for patching i use "Cygwin"! Only errors ...

Hunk #1 Failed at 1
Hunk #2 Failed at 12
Hunk #3 Failed at 39
.... and so on

It is not possible to Patch this Version!

The thumbnails from embimage generated wrong - the size is not minimzied - the thumbnails have all the full-original-size!

I tested "Development releases" from emfield - same Problem!

Last 2 days i try hard to break this problem - it is not possible!

I need the Thumbnails for my Views-Block - it is absolutly important but i go mad!

Thumbnails from embvideo are running but not from embimage!

What i make wrong - i am so frustrated?

Sorry for my bad english!

Berliner-dupe’s picture

Status: Closed (fixed) » Needs review
Babalu’s picture

patch is against the latest 6.x-1.x-dev

Berliner-dupe’s picture

Latest Version dont work correct!

Latest Version make "Preview-Images" in "files Drupal-directory" but no "thumbnails" .... All settings are correct! My thumbnails-settings are 100 px - "Preview-Image-Setting" -> 240px ....

Preview-Images are ok but Thumbnails are not applied!

Berliner-dupe’s picture

Status: Needs review » Needs work

Hello,

here is a second problem!

When i make the settings for "Preview-Images" only 100 px width and this images i take for "Thumbnail alternate" (the real thumbnails are not applied) then emfield save this images in files-directory! (files/emimage-custom_url-http:--.......jpg) Thats ok!

Now i will make a block with Views - block must show 10 of local Preview-Images ( one image (Image1) from 10 Nodes).

In Views/Block i set: Field -> Content -> Image1 - the format from "Image1" i set to "Preview Size Image" - i save

When i call the block in Node - Views show me the 10 images but all Image-Urls are from external !

<img src="http://www.external-URL.com/images/5662.jpg" alt="" title="" width="100" height="180" class="custom_url" />

The width and high is correct (assumed from "Preview-Setting") but the Image URL is wrong!

Image-URL must be <img src="sites/default/files/emimage-custom_5662.jpg" alt="" title="" width="100" height="180" class="custom_url" /> (there are the local Previw-Images)

Is the Module full of bugs or i am dimwitted???

Or has anyone an other idea?

I am desperate!

(Sorry for my bad english)

andrewlevine’s picture

Status: Needs work » Fixed

Hi...the patch from this issue is already in version 6.x-1.18. Please open new issues for each of your comments. It will be easier to track them that way.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.