Display preview assets
  • Hello admin.

    This time i'm trying to display a preview when you're uploading an image.

    I'm using 'display_preview' but i don't know where the preview is displaying. Altought i have this property in TRUE i can't see the preview in the modal Assets > Upload.

    Thanks for your help.
  • The preview should be displaying right by the form input field. Are you seeing any errors in the browser console?
  • Nothing in console. I have the property like this:

    $fields['userfile']['display_preview']= TRUE;


    $fields['userfile'] = array('type' => 'file' , 'overwrite' => TRUE, 'display_preview' => 'TRUE');

    and i can only see the overwrite option nothing else.
  • I think in your case, you need to specify either a "folder" or "upload_path" parameter. The folder is relative to the /assets directory whereas the upload_path is the server path to upload to.
  • How can i obtain the name that appear in the file type form? First appear a message that says 'ningun archivo seleccionado' and it changes automatically when i choose an image.
  • I'm sorry but I don't quite understand your question.
  • It's ok.

    In the modal Assets > Upload. When you select an image the name of the image appear in the file field. I want to capture that name in a different variable. I hope you understand, thanks admin.
  • Are you wanting to do this with Javascript or PHP? Also, what are you wanting to do with that file name? If you are wanting to perhaps do something with the file itself, there are on_after_post model hooks you can use to further manipulate things on save:

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!