Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Problem with pictures (avatars and uploads)

1235

Comments

  • thanks @river I checked all the permissions and they're 777 and still no luck. The thumb files do get written, they just don't display. It's pretty much the same issue I have two years ago which @peregrine fixed (see above.)

  • I did get the Advanced Editor from 2.3b.1 to work but it didn't create thumbnails either. It did insert the photos into the post which the current Advanced Editor wasn't doing for me. Seems like I need to modify the Advanced Editor to work with my server, any ideas?

  • If the GD extension is no longer available things like that will happen

    @meshugy said:
    thanks @river I checked all the permissions and they're 777 and still no luck. The thumb files do get written, they just don't display. It's pretty much the same issue I have two years ago which @peregrine fixed (see above.)

    Sure they are available? If I look at your example, I get a link to this picture:
    http://www.djangobooks.com/forum/uploads/editor/y4/flzgey999cta.jpg

    The thumbs address should be:
    http://www.djangobooks.com/forum/uploads/editor/thumb/y4/flzgey999cta.jpg

    Opening that address gives a 404.

    Please make sure that this file exists or please tell the path to the thumb for this file (see the table Media and look for the filename to find the thumbs path).

    From what I see I would say your GD extension is no longer available...

  • Forget about what I've said about the thumb url. Thumbs are not named as easy as that...

  • Thanks @R_J

    Sorry, I don't know what a GD extension is.

    The thumbs are accessible.....here's one that was created last night:

    http://www.djangobooks.com/forum/uploads/editor/thumb/nw/919a4xonzszh.jpg

    So it's not a permission issue.

    @peregrine fixed the same problem for me with File Upload by changing:

    Img(Asset('/plugins/FileUpload/images/file.png'), array('class' => 'ImageThumbnail', 'height' => GetValue('ThumbHeight', $Media))).

    to

    Img('plugins/FileUpload/images/file.png', array('class' => 'ImageThumbnail', 'height' => GetValue('ThumbHeight', $Media))).

    I assume I have to make the same modification to Advanced Editor but I don't know how.

  • RiverRiver MVP
    edited August 2016

    @meshugy said:
    Thanks @R_J

    Sorry, I don't know what a GD extension is.

    The thumbs are accessible.....here's one that was created last night:

    http://www.djangobooks.com/forum/uploads/editor/thumb/nw/919a4xonzszh.jpg

    So it's not a permission issue.

    1 - forget about past problem.
    2 - you have a new issue, new situation, new problem, new fix
    3 - see 1 and 2

    now to determine gd

    https://vanillaforums.org/discussion/comment/205833/#Comment_205833

    or

    create a test file

    <?php
    var_dump(gd_info());
    ?>
    

    Based on what you said, thumbnail is created properly and the image is saved.
    Now you need to see if the thumbnail path is in the media table for the image you are referencing

    so look for the insertion date and the file name. and determine if a thumbnail path is present in the table.

    you don't have a 404 - it seems like you don't have a thumbnail path being retrieved therefore, you get the file icon deal, instead of your image.

    next step start is to add decho statements to follow.

    but first disable the fileupload plugin from the dashboard, not via the config.php

    then start a new discussion and attach an image. if you are using ver 1.7.7 of editor just remove the image info from the body of discussion and the attachment will show. 1.7.2 of editor won't automatically insert and will show attachments

    then post a screen shot of your new discussion after saving.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • RiverRiver MVP
    edited August 2016

    using the 1.7.2 editor (original)

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/views/attachments.php#L13

    <?php foreach ($attachments as $attachment): ?>
    <?php
    $isOwner = (Gdn::session()->isValid() && (Gdn::session()->UserID == $attachment['InsertUserID']));
    

    change to

    <?php foreach ($attachments as $attachment): ?>
    <?php
    decho ($attachment);
    $isOwner = (Gdn::session()->isValid() && (Gdn::session()->UserID == $attachment['InsertUserID']));
    

    and login as admin and look at discussion and post results of dump.

    the thumbnail path might be null! is it. probably yes.

    what about the media table does, it have the thumbnail path.

    meaning did the thumbnail path get written to the table, is it null, or is the retrieval of the info screwed up.

    probably the writing of the path. in that case more dechos in

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L835

    you need to test here - not sure if decho will work. you might need to send it to a debug log.

    change

     if ($generate_thumbnail) {
    $thumbUrl = url('/utility/mediathumbnail/'.$MediaID, true);
    }
    

    to temporarily.

     if ($generate_thumbnail) {
    $thumbUrl = url('/utility/mediathumbnail/'.$MediaID, true);
    decho($thumbUrl);
    }
    

    post the result of that.

    if you don't see a decho.

    you could add a die(); breifly or use a debuglog.

    not sure if same technique in vanilla 2.2.1
    https://vanillaforums.org/discussion/26786/tutorial-how-to-enable-a-debug-log-and-collect-debugging-information

    or you could use a file_put_contents to your upload folder (since it is 777)
    ala https://vanillaforums.org/discussion/comment/242660/#Comment_242660

    then if no url, you need to dig deeper here..

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L1535

    and determine what the value of

    $filepath_parsed

    and what is
    $filepath_parsed['SaveName']

    dump it or log it.

    also determine values here:

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L1522

    if ($thumb_payload['success'] === true) {
    

    is it true?

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L1547

    or is the thumbpath being nulled out here

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L1560

    It might have been better to start a new discussion - since the advanced editor didn't exist when this discussion began, and the difficulty you are having deals with the advanced editor plugin in vanilla 2.2.1

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • thanks @River

    Your response is a bit technical for me but I did the drecho edit and received this response:

    DEBUG: Array ( [MediaID] => 8258 [Name] => 20160817_124719.jpg [Path] => editor/y4/flzgey999cta.jpg [Type] => image/jpeg [Size] => 975307 [InsertUserID] => 1202 [DateInserted] => 2016-08-18 02:53:43 [ForeignID] => 15086 [ForeignTable] => discussion [ImageWidth] => 2560 [ImageHeight] => 1440 [ThumbWidth] => 0 [ThumbHeight] => 0 [ThumbPath] => [StorageMethod] => local [InBody] => )

    So there is no ThumbPath. I looked in the database and the ThumbPath is not being stored there. All the entries are blank. Do you have any idea what may cause this?

  • RiverRiver MVP
    edited August 2016

    here is the beginning or the end of your problem

    [ThumbPath] =>
    

    [StorageMethod] => local

    is null.

    you could use phpmyadmin and look in media table for name 20160817_124719.jpg

    and see if the thumbpath is null in media table.

    probably yes but confirm.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • RiverRiver MVP
    edited August 2016

    @River said:
    using the 1.7.2 editor (original)

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/views/attachments.php#L13

    <?php foreach ($attachments as $attachment): ?>
    <?php
    $isOwner = (Gdn::session()->isValid() && (Gdn::session()->UserID == $attachment['InsertUserID']));
    

    change to

    <?php foreach ($attachments as $attachment): ?>
    <?php
    decho ($attachment);
    $isOwner = (Gdn::session()->isValid() && (Gdn::session()->UserID == $attachment['InsertUserID']));
    

    and login as admin and look at discussion and post results of dump.

    the thumbnail path might be null! is it. probably yes.

    ok that is null based on your post above.

    now you need to proceed here follow the info below and drill down and see if the payload is successful down below and the other lines.

    what about the media table does, it have the thumbnail path.

    meaning did the thumbnail path get written to the table, is it null, or is the retrieval of the info screwed up.

    probably the writing of the path. in that case more dechos in

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L835

    you need to test here - not sure if decho will work. you might need to send it to a debug log.

    change

     if ($generate_thumbnail) {
    $thumbUrl = url('/utility/mediathumbnail/'.$MediaID, true);
    }
    

    to temporarily.

     if ($generate_thumbnail) {
    $thumbUrl = url('/utility/mediathumbnail/'.$MediaID, true);
    decho($thumbUrl);
    }
    

    post the result of $thumbUrl from the point above in code.

    if you don't see a decho.

    you could add a die(); breifly or use a debuglog.

    not sure if same technique in vanilla 2.2.1
    https://vanillaforums.org/discussion/26786/tutorial-how-to-enable-a-debug-log-and-collect-debugging-information

    or you could use a file_put_contents to your upload folder (since it is 777)
    ala https://vanillaforums.org/discussion/comment/242660/#Comment_242660

    then if no url, you need to dig deeper here..

    post the result of this

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L1535

    and determine what the value of

    $filepath_parsed

    and what is
    $filepath_parsed['SaveName']

    dump it or log it.

    also determine values here:

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L1522

    if ($thumb_payload['success'] === true) {
    

    is it true?

    here post the result of debugging value of $thumb_payload['success']

    check here did it get reset here.

    or is the thumbpath being nulled out here

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L1560

    It might have been better to start a new discussion - since the advanced editor didn't exist when this discussion began, and the difficulty you are having deals with the advanced editor plugin in vanilla 2.2.1

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • Can @hgtonight please move/start a new discussion under editor plugin because this discussion is not about FileUpload plugin starting with the last post meshuguy started… thanks..

  • https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L835

    you need to test here - not sure if decho will work. you might need to send it to a debug log.

    change

     if ($generate_thumbnail) {
    $thumbUrl = url('/utility/mediathumbnail/'.$MediaID, true);
    }
    

    to temporarily.

     if ($generate_thumbnail) {
    $thumbUrl = url('/utility/mediathumbnail/'.$MediaID, true);
    decho($thumbUrl);
    }
    

    post the result of $thumbUrl from the point above in code.

    I tried this but it didn't produce an debugging info

  • also determine values here:

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L1522

    if ($thumb_payload['success'] === true) {
    

    is it true?

    here post the result of debugging value of $thumb_payload['success']

    Yes, $thumb_payload['success'] === true)

  • RiverRiver MVP
    edited August 2016

    @meshugy

    I'm gonna clear you up. But first listen to this, then put your debugging gloves on and I'll provide you baby steps....

    https://www.youtube.com/watch?v=mXSEc2p5-QA

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • step 1 from here as suggested before https://vanillaforums.org/discussion/26786/tutorial-how-to-enable-a-debug-log-and-collect-debugging-information

    modified

    -1 add these statements to your conf/config.php

    $Configuration['Garden']['Errors']['LogEnabled'] = TRUE;
    $Configuration['Garden']['Errors']['LogFile'] = 'uploads/DebugLog';

    assuming uploads is the name of your uploads folder.

    • 2 ok when you start debugging the statements should be in a file called DebugLog in your uploads folder of your forum. You can make it any name or folder you want under your forum directory, but the directory has to be writeable via permissions and ownership.

    • 3 if nothing is written to your DebugLog - make sure config statements are set and folder permissions are correct.

    next

    -4 first debug statement

    after this line https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L1534

    change

    $filepath_parsed = $Upload->saveAs($thumb_destination_path, $target, array('source' => 'content'));

    to

        $filepath_parsed = $Upload->saveAs($thumb_destination_path, $target, array('source' => 'content'));
        //debuglog
                       ob_start();
            decho($filepath_parsed);
            $Result = ob_get_clean();
    
            LogMessage(__FILE__,__LINE__,'Object','Method',"filepath_parsed here  -" .$Result );  
    
    • 5 second debug statement

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/editor/class.editor.plugin.php#L1521

    change this

    if ($thumb_payload['success'] === true) {

    to

        ob_start();
        decho($thumb_payload);
        $Result = ob_get_clean();
    
        LogMessage(__FILE__,__LINE__,'Object','Method',"thumb payload here -" .$Result );  
    
            if ($thumb_payload['success'] === true) {
    

    change

       <?php foreach ($attachments as $attachment): ?> 
    
    
         <?php 
    
          $isOwner = (Gdn::session()->isValid() && (Gdn::session()->UserID == $attachment['InsertUserID'])); 
    

    to

     <?php foreach ($attachments as $attachment): ?>
    
          <?php
    decho($attachment);
    if (function_exists('gd_info')) {
    decho(gd_info());
    } else {
    decho("puke - pay attention and install gd");
    }
    
          $isOwner = (Gdn::session()->isValid() && (Gdn::session()->UserID == $attachment['InsertUserID']));
    
    • step 7

    after you changed config and CAREFULLY AND COMPLETELY followed the steps above

    create a new discussion on your django forum. then add an image to the discussion.
    then save that discussion.

    post a screen shot before the save and after the save.

    read above statement a few times.

    • step 8

    if your debug log from config statement was 'uploads/DebugLog' then look in uploads folder for the DebugLog and zip it up and attach it as a file here.

    based on the gd_info result and the $thumb_payload info (this is fairly large) and the filepath_parsed we should be able to figure out where the issues is. gd version, or path problem of memory limit or file, or json or whatever.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • RiverRiver MVP
    edited August 2016

    @meshugy - please follow all the steps above, I can analyze log when I sign back on.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • @meshugy - please follow all the steps above, I can analyze log when I sign back on.

    final step after above is completed.

    step 9

    after you are finished logging the info you can remove the 2 config statements, and restore the two files back to original so you don't keep logging info.> @River said:

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • ok, I followed all the steps. Debug log below:

    `20 Aug 2016 - 23:02:00: [Garden] /home/gypsypicking/djangobooks.com/forum/plugins/editor/class.editor.plugin.php, 1539, Object.Method(), filepath_parsed here -
    20 Aug 2016 - 23:03:55: [Garden] /home/gypsypicking/djangobooks.com/forum/plugins/editor/class.editor.plugin.php, 1525, Object.Method(), thumb payload here -
    20 Aug 2016 - 23:03:55: [Garden] /home/gypsypicking/djangobooks.com/forum/plugins/editor/class.editor.plugin.php, 1543, Object.Method(), filepath_parsed here -
    20 Aug 2016 - 23:04:31: [Garden] /home/gypsypicking/djangobooks.com/forum/plugins/editor/class.editor.plugin.php, 1525, Object.Method(), thumb payload here -

    DEBUG: Array
    (
        [hard_limits] => Array
            (
                [max_megapixels] => 10
                [min_dimension] => 0
                [php_memory_limit] => 90M
                [php_post_max_size] => 65M
                [php_upload_max_filesize] => 64M
                [max_filesize_bytes] => 20971520
                [quality] => 85
            )
    
        [options] => Array
            (
                [height] => 128
                [width] => 0
                [crop] => 
                [max_width] => 
                [max_height] => 
                [quality] => 85
                [max_megapixels] => 10
                [max_memory_bytes] => 94371840
                [max_filesize_bytes] => 20971520
                [exif] => 
                [allow_bigger] => 
                [debug] => 
                [compression_level] => 7
            )
    
        [success] => 1
        [gd] => 1
        [file_exists] => 1
        [filesize_bytes] => 419426
        [hard_limits_respected] => 1
        [allowed_files] => Array
            (
                [0] => jpg
                [1] => jpeg
                [2] => gif
                [3] => png
                [4] => bmp
                [5] => ico
                [6] => 
            )
    
        [file] => /home/gypsypicking/djangobooks.com/forum/uploads/editor/fn/sdd1ndp6oq7o.jpg
        [extension] => jpg
        [dst_directory] => /home/gypsypicking/djangobooks.com/forum/uploads/editor/thumb/hd
        [dst_writable] => 1
        [dst_filename] => t1gjthwqwx3o
        [dst_extension] => jpg
        [calculate_image_values] => 1
        [mime_subtype] => jpeg
        [mime_type] => image
        [width] => 2730
        [height] => 2394
        [orientation] => landscape
        [pixels] => 6535620
        [megapixels] => 6.53562
        [bytes_per_pixel] => 3
        [memory_pad] => 1.7
        [memory_required_bytes] => 33426947.894737
        [sha1_file] => 1b333f396cf84582cd6836bc9cda97e24480149d
        [image_start_processing] => 1
        [result_height] => 128
        [result_width] => 145.9649122807
        [result_orientation] => landscape
        [croppable] => 
        [result_pixels] => 18683.50877193
        [memory_required] => 31.8784216831M
        [memory_peak_usage_script_bytes] => 13238376
        [memory_peak_usage_script] => 12.6250991821M
        [dst] => /home/gypsypicking/djangobooks.com/forum/uploads/editor/thumb/hd/t1gjthwqwx3o.jpg
        [result_sha1_file] => 99108c629ad3606c75622a953a7a5296eeade20f
        [result_filesize_bytes] => 5436
        [memory_peak_usage_image_bytes] => 32912280
        [memory_peak_usage_image] => 31.3875961304M
        [memory_peak_usage_total_bytes] => 46150656
        [memory_peak_usage_total] => 44.0126953125M
    )
    

    20 Aug 2016 - 23:04:31: [Garden] /home/gypsypicking/djangobooks.com/forum/plugins/editor/class.editor.plugin.php, 1543, Object.Method(), filepath_parsed here -

    DEBUG: Array
    (
        [Name] => editor/thumb/hd/t1gjthwqwx3o.jpg
        [Type] => 
        [SaveName] => editor/thumb/hd/t1gjthwqwx3o.jpg
        [SaveFormat] => %s
        [Url] => http://www.djangobooks.com/forum/uploads/editor/thumb/hd/t1gjthwqwx3o.jpg
    )
    

    `

  • RiverRiver MVP
    edited August 2016

    @meshugy said:
    ok, I followed all the steps.

    Almost but not quite.

    You provided good info with most steps but ...
    I thought Sharon Jones would help you get the focus on, or maybe my instructions were not clear, or perhaps your unable to do things for some reason unknown to me (perhaps you are on mobile or can't zip).

    Step 7 - you didn't post the screenshot images before and after I asked you to post. It would give me more insights on your settings, plugins, apps, etc and see it in action

    step 8 - I was hoping for an attachment and zip (easier for me to compare (copy and paste changes format), but I survived.

    step 3 - where is the gdinfo information that would be reflected in step 7.

    specific steps for specific reasons for me to help you.

    now based on what you posted.

    With the info you posted I believe your problem has to do with your memory_limit.

    I think you pooped out after the thumbnail was created,
    Use the version checker plugin (which has phpinfo included) or create your own phpinfo page.

    determine where your configuration file is located from phpinfo. modify the php.ini file to increase the

    memory limit to 128M or 192M or 256M , restart server.

    -1 is unlimited - I'd consider the above though.

    verify if memory_limit has changed with phpinfo

    test uploading the image.

    Does it work?

    I don't know if you tested uploading an image with a smaller footprint. Try a jpg file that has a height and width
    400 x 400 or so.

    your image height and width is huge

    [width] => 2730
    [height] => 2394

    you could try downloading this thumbnail http://www.djangobooks.com/forum/uploads/editor/thumb/hd/t1gjthwqwx3o.jpg

    which is 145 x 128 and see if you get a thumbnail.

    if smaller images don't work, or large image doesn't work after changing memory.

    you will need to provide more info and perhaps debug the class model and give more info e.g. version of php, server type apache, nginx or whatever, and a screenshot or values in media table for the images that doen't work.

    you could ini_set or add an option to try to increase on the fly, I would change the ini file if it were me.

    ask your host to help you increase memory_limit - if you can't tell after these instructions or googling, or searching this forum.

    as an aside it looks like version 1.7.2 doesn't deal with -1 memory_limit on the initial attachment phase but a reload would work. Also editor 1.7.2 has several references to file upload plugin.

    when adjusting memory, you will need to test by adding images. the images that are already added will not be fixed, you would need to manually add

     'StorageMethod' =>  ""  (not sure if this present in future versions.
    'ThumbWidth' => 
    'ThumbHeight' => 
    'ThumbPath' => 
    

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

Sign In or Register to comment.