I'm adding some fields to Drupals site-information form. Textfields and managed_file fields. Images are uploaded there and not in my panel panes edit form.

Now I want to make the additional fields I've added, or just the whole form be rendered in a custom panel content_type. I have no issue getting the textfields themselves using

$block->content .= filter_xss_admin(variable_get('phonenumber', ''));

however I also need to render my managed_file. How would I go about doing so?

| improve this question | | | | |

Okay, it's not my day today :D

Here's how to do what you were asking:

// Load the managed file. You need this so you can get the URI.
$file = file_load(YOUR_FILE_ID);
// Generate the output.
$output = theme('image', array(
  'alt' => t('Your image alt title'),
  'title' => t('Your image human title'),
  'attributes' => array('src' => $file->uri),
| improve this answer | | | | |
  • You could also add the file as a required Ctools context iirc. – mradcliffe Mar 21 '16 at 15:47
  • Where would I put this? I tried function MYMODULE_PLUGINNAME_content_type_render($subtype, $conf, $panel_args) { $block = new stdClass(); $file = file_load('phoneicon'); $output = theme('image', array( 'alt' => t('Alt'), 'title' => t('Title'), 'attributes' => array('src' => $file->uri), )); $block->content = $output; } but it just returns an img tag with my normal url (example.com) as source. – Carl Mar 21 '16 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.