How can i show external/3rd party images in slider?
Tue, 11/24/2009 - 05:28 — Anonymous
When i add images to slider, i must always upload images to my host. For example; i want to show "http://www.google.com/images/nav_logo7.png" image directly in slider without self-host. Simply how i can do it? Thanks, regards...
You need to add a URL field for this image to your CCK content type and view and use this field in the preprocess function in the template.php file instead of the image field.
Thanks for the answer. First off all i must specify that i am a starter at drupal. i can add url field but i do not know how can i edit my template function? can you write a "how to note" about that?
I have added the code to both preprocess functions.
// add image from URL and
// add pager item image from URL
You need to change the fieldname of the URL field you use.
/**
* Override or insert variables into the ddblock_cycle_block_content templates.
* Used to convert variables from view_fields to slider_items template variables
*
* @param $vars
* An array of variables to pass to the theme template.
*
*/function marinelli_preprocess_ddblock_cycle_block_content(&$vars){if($vars['output_type']=='view_fields'){$content=array();// Add slider_items for the template // If you use the devel module uncomment the following line to see the theme variables// dsm($vars['settings']['view_name']); // dsm($vars['content'][0]);// If you don't use the devel module uncomment the following line to see the theme variables// drupal_set_message('<pre>' . var_export($vars['settings']['view_name'], true) . '</pre>');// drupal_set_message('<pre>' . var_export($vars['content'][0], true) . '</pre>');if($vars['settings']['view_name']=='sunumlar'){if(!empty($vars['content'])){foreach($vars['content']as$key1=>$result){// add slide_image variable if(isset($result->node_data_field_sunum_kisa_baslik_field_sunum_resim_fid)){// get image id$fid=$result->node_data_field_sunum_kisa_baslik_field_sunum_resim_fid;// get path to image$filepath= db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d",$fid));// use imagecache (imagecache, preset_name, file_path, alt, title, array of attributes)if(module_exists('imagecache')&&is_array(imagecache_presets())&&$vars['imgcache_slide']<>'<none>'){$slider_items[$key1]['slide_image']=
theme('imagecache',$vars['imgcache_slide'],$filepath,
check_plain($result->node_title));}else{$slider_items[$key1]['slide_image']='<img src="'. base_path().$filepath.'" alt="'. check_plain($result->node_title).'"/>';}}// add image from URLif(isset($result->[***fieldname of URL field***])){$slider_items[$key1]['slide_image']='<img src="'.$result->[***fieldname of URL field***].'" alt="'. check_plain($result->node_title).'"/>';}// add slide_text variableif(isset($result->node_data_field_sunum_kisa_baslik_field_sunum_kisa_govde_value)){$slider_items[$key1]['slide_text']= check_markup($result->node_data_field_sunum_kisa_baslik_field_sunum_kisa_govde_value);}// add slide_title variableif(isset($result->node_title)){$slider_items[$key1]['slide_title']= check_plain($result->node_title);}// add slide_read_more variable and slide_node variableif(isset($result->nid)){$slider_items[$key1]['slide_read_more']= l('Read more...','node/'.$result->nid);$slider_items[$key1]['slide_node']= base_path().'node/'.$result->nid;}}}}$vars['slider_items']=$slider_items;}}/**
* Override or insert variables into the ddblock_cycle_pager_content templates.
* Used to convert variables from view_fields to pager_items template variables
* Only used for custom pager items
*
* @param $vars
* An array of variables to pass to the theme template.
*
*/function marinelli_preprocess_ddblock_cycle_pager_content(&$vars){if(($vars['output_type']=='view_fields')&&($vars['pager_settings']['pager']=='custom-pager')){$content=array();// Add pager_items for the template // If you use the devel module uncomment the following lines to see the theme variables// dsm($vars['pager_settings']['view_name']); // dsm($vars['content'][0]); // If you don't use the devel module uncomment the following lines to see the theme variables// drupal_set_message('<pre>' . var_export($vars['pager_settings'], true) . '</pre>');// drupal_set_message('<pre>' . var_export($vars['content'][0], true) . '</pre>');if($vars['pager_settings']['view_name']=='sunumlar'){if(!empty($vars['content'])){foreach($vars['content']as$key1=>$result){// add pager_item_image variableif(isset($result->node_data_field_sunum_kisa_baslik_field_sunum_resim_fid)){$fid=$result->node_data_field_sunum_kisa_baslik_field_sunum_resim_fid;$filepath= db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d",$fid));// use imagecache (imagecache, preset_name, file_path, alt, title, array of attributes)if(module_exists('imagecache')&&is_array(imagecache_presets())&&$vars['imgcache_pager_item']<>'<none>'){$pager_items[$key1]['image']=
theme('imagecache',$vars['pager_settings']['imgcache_pager_item'],$filepath,
check_plain($result->node_data_field_sunum_kisa_baslik_field_sunum_kisa_baslik_value));}else{$pager_items[$key1]['image']='<img src="'. base_path().$filepath.'" alt="'. check_plain($result->node_data_field_sunum_kisa_baslik_field_sunum_kisa_baslik_value).'"/>';}}// add pager item image from URLif(isset($result->[***fieldname of URL field***])){$pager_items[$key1]['image']='<img src="'.$result->[***fieldname of URL field***].'" alt="'. check_plain($result->node_data_field_sunum_kisa_baslik_field_sunum_kisa_baslik_value).'"/>';}// add pager_item _text variableif(isset($result->node_data_field_sunum_kisa_baslik_field_sunum_kisa_baslik_value)){$pager_items[$key1]['text']= check_plain($result->node_data_field_sunum_kisa_baslik_field_sunum_kisa_baslik_value);}}}}$vars['pager_items']=$pager_items;}}
- We install and configure ddblock for $40, see: packages
- Slideshow theme customizations, please fill out the design requirements questionnaire to create an efficient workflow.
- For other drupal related services contact us via the contact form
Re: How can i show external/3rd party images in slider?
You need to add a URL field for this image to your CCK content type and view and use this field in the preprocess function in the template.php file instead of the image field.
Hope this helps you further, please let me know.
Thanks for the answer. First
Thanks for the answer. First off all i must specify that i am a starter at drupal. i can add url field but i do not know how can i edit my template function? can you write a "how to note" about that?
My template function is: http://pastebin.com/m5851b8ff
Default function which i edit for my template: http://pastebin.com/m3699c0a8
Thanks, regards...
Re: Thanks for the answer...
I have added the code to both preprocess functions.
// add image from URL and
// add pager item image from URL
You need to change the fieldname of the URL field you use.
Hope this helps you further, please let me know.