Skip to content

Instantly share code, notes, and snippets.

@bjornbjorn
Created April 10, 2013 16:58
Show Gist options
  • Save bjornbjorn/5356442 to your computer and use it in GitHub Desktop.
Save bjornbjorn/5356442 to your computer and use it in GitHub Desktop.
Replacing {filedir_1} in channel_data
$grid_image = str_replace('{filedir_1}', '/uploads/', $grid_image);
/**
This is how the above _should_ be done:
if (preg_match('/^{filedir_(\d+)}/', $src, $matches))
{
$filedir_id = $matches[1];
$this->EE->load->model('file_upload_preferences_model');
$upload_dest_info = $this->EE->file_upload_preferences_model->get_file_upload_preferences(FALSE, $filedir_id);
$src = str_replace('{filedir_'.$filedir_id.'}', $upload_dest_info['server_path'], $src);
}
*
* .., but premature optimalization ftw!
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment