Hello

(google translate is my friend)

I noticed a small anomaly in the uploaded images. Indeed, the maximum size of the images is not taken into account when uploading images.

I set the limit to 1 MB does not have images of more than 1 Mega octed.

I could upload (as a member) without a problem image 1.7 MB

Note that I have enabled the module plupload.

How to take into account this limit?

I marked that it is a bug but I'm not sure this is the case.

Bonjour

J'ai remarqué une petite anomalie au niveau des images uploadés. En effet le poids maximal des images n'est pas pris en compte lors de l'upload des images.

J'ai fixé comme limite 1 MB pour ne pas avoir des images de plus de 1 Méga-octed.

J'ai pu uploader (en tant que membre) sans problème une image de 1,7 Mo.

Je précise que j'ai activé le module plupload.

Comment prendre en compte cette limite ?

J'ai marqué que c'est un bug mais je ne suis pas sur que ce soit le cas.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcisio’s picture

Title: Weight images » Scald Image to respect scald_thumbnail field maximum file size limit
Version: 7.x-1.1 » 7.x-1.x-dev
Category: bug » feature

The point here is you may want to limit the thumbnail field to something like 50 KB 100x100 pixel so that you don't have big thumbnails, but still keep the original images in Scald Image. And if Scald Image is the only image provider, then it'd be great to have an option to respect the field file size limit.

A-snowboard’s picture

Hello,

I do not mean the weight of the sticker, but the original weight of the image file.

A member can upload an image of 40 MB if desired.

Now I want to limit an image to 1MB

In the manager scald image fields I "Maximum Upload Size"

I put 1MB, it is obviously not taken into account because I can upload pictures heavier.

jcisio’s picture

In the Scald Image provider, both image and thumbnail are the same file.

A-snowboard’s picture

ok, thank you for accuracy.

but how can I do to reduce the weight of the picture? I have set the limit, but this is not taken into account.

jcisio’s picture

This is a feature request, so you can't do it yet, unless you code with hook_entity_presave() for example to resize the uploaded image.

gifad’s picture

Status: Active » Needs work
FileSize
838 bytes

The attached patch does the job for plupload upload method;
(cf sites/all/modules/plupload/README.txt)

set status to needs work, as this should be done for "normal" file upload also (and I could not make it);

but this can be a convenient workaround for A-snowboard ;)

gifad’s picture

Status: Needs work » Needs review
FileSize
943 bytes

updated for latest (7.x-1.1+19) dev release...

A-snowboard’s picture

Thank you for your patch

I'll test it and you tennir aware.

By cons I do not have the same code as I 7.x-1.1 release

    '#upload_location' => scald_atom_thumbnail_path('image'),
    '#upload_validators' => array('file_validate_extensions' => array('jpg jpeg png gif')),
  );
}

/**
 * Implements hook_scald_add_atom_count().
 */
function scald_image_scald_add_atom_count(&$form, &$form_state) {
  if (is_array($form_state['values']['file'])) {
    return max(count($form_state['values']['file']), 1);
  }
  return 1;
}

/**
 * Implements hook_scald_add_form_fill().
 */
function scald_image_scald_add_form_fill(&$atoms, $form, $form_state) {
  foreach ($atoms as $delta => $atom) {
    if (is_array($form_state['values']['file']) && module_exists('plupload')) {
      module_load_include('inc', 'scald', 'includes/scald.plupload');
      $file = scald_plupload_save_file($form_state['values']['file'][$delta]['tmppath'], $form['file']['#upload_location'] . $form_state['values']['file'][$delta]['name']);
    }	

I tested as I can and come back.

A-snowboard’s picture

The code asks me trouble with my version of scald.

I send you this evening my error and the screen messages.

jcisio’s picture

Status: Needs review » Needs work

Since it is a feature request, and there are use cases to bypass the field limit settings, I think Scald Image should have options to:
- Respect the field filesize limit settings: a checkbox.
- Or to specify an independant maximum image size.

A-snowboard’s picture

Hello,

Complettement I forgot to put the mistakes that I had with the patch.
(I really do not have time with the academic year)
I do that whenever I can.

In my opinion, if it is an addition of functionality, you just can limit the maximum input size.

Raphael Apard’s picture

hi,

Here a patch to force scald_image to "Respect the field settings". I'm pretty sure than the 2 functions "getFieldUploadValidators" and "getFieldDescription" don't have to be in ScaldAtomController. Just put them here becasuse of "getThumbnailPath".

jcisio, what the point of having a checkbox to "Respect the field filesize limit settings". Each scald type have his own instance of thumbnail field no ?

Simon Georges’s picture

Issue summary: View changes
Status: Needs work » Needs review

Changing the status back to "Needs review", as there is a new patch.

shortspoken’s picture

Thanks @Raphael Apard for the patch. It works as expected but the description is printed twice. See attached screenshot.

jcisio’s picture

Status: Needs review » Needs work

NW because of #14.

A-snowboard’s picture

Hello,

(sorry google translate is my friend)

I tried to apply the patch #12, I am entitled to the white screen of death!

May be a problem with the code for the file: ScaldAtomController.inc?

Here is my current code:

<?php
/**
 * @file
 * This file contains the Scald Atom controller.
 */

/**
 * Controller class for Scald Atoms.
 *
 * This extends DrupalDefaultEntityController, adding special handling
 * for ScaldAtom objects.
 */
class ScaldAtomController extends DrupalDefaultEntityController {
  /**
   * Overrides DrupalDefaultEntityController::attachLoad().
   */
  protected function attachLoad(&$atoms, $revision_id = FALSE) {
    foreach ($atoms as $atom) {
      $atom->data = unserialize($atom->data);
    }

    parent::attachLoad($atoms, $revision_id);
  }
}
al.ex’s picture

Hello,

I re-created the patch against the latest dev version (commit 665de6d).

nagy.balint’s picture

Generalized the functions a little bit, and fixed the issue in #14.

Rerolled the patch for latest dev.

nagy.balint’s picture

Status: Needs review » Fixed

Thanks! Committed.

Status: Fixed » Closed (fixed)

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