asset preview for off server assets

edited June 2016 in Feature Requests
I'm building a module to manage image data from a data feed we receive. The image files are held on a remote server and we are just maintaining a link to them. As there are several images per item, I'm storing the links as JSON, this also allows me to use a repeatable block in Form_fields, which is very tidy:
$fields['gallery'] = array( 'display_label' => FALSE, 'add_extra' => FALSE, 'repeatable' => TRUE, 'type' => 'template', 'label' => 'Gallery', 'limit' => 12, 'class' => 'repeatable', 'title_field' => 'cap_id', 'fields' => array( 'viewpoint' => array( 'type' => 'int', 'multiple' => TRUE ), 'src' => array( 'type' => 'asset', 'multiple' => TRUE, 'img_styles' => 'float: left; width: 100px;', 'after_html' => "<img src='{__src__}'>" ), ) );
The image preview doesn't appear, I assume this is because the image is on a remote site.

How could I drop a preview image into the repeatable block?

Regards

David

Comments

  • edited 10:34PM
    Is there a broken image appearing or no image at all. If it is broken, what is the src path being used?
  • edited 10:34PM
    it's a broken image link.
    I'm not sure how to reference the $gallery->src. At what point are the values dropped into the template?

    Cheers
  • edited 10:34PM
    It would be in the $values array that is passed to the form_fields method if you are editing. If it is a new record then it won't exist. Since only form field values get saved in the JSON, you could try saving the __src__ value as just another hidden field value. You could use an on_before_save model hook to save the value in the JSON (would need to loop through the $_POST['gallery'] value). Then you could use javascript to perhaps grab all the hidden field values and use it to replace the after_html {__src__} value.
Sign In or Register to comment.