我遇到了图片模块和列表加载的问题。所以我的结构是内容类型,其中一些字段是图像设置显示图片。
在另一页上,我不想显示该内容类型的2个对象。所以我从数据库和预处理字段中选择它。对于普通字段,它可以,因为我只需要它们的值,但是对于图片我需要所有其他数据,如断点,主题。 对于图像基本上我得到了:
array (size=1)
'und' =>
array (size=1)
0 =>
array (size=18)
'fid' => string '3023' (length=4)
'uid' => string '1' (length=1)
'filename' => string 'profile_picture.jpg' (length=19)
'uri' => string 'public://profile_picture.jpg' (length=28)
'filemime' => string 'image/jpeg' (length=10)
'filesize' => string '325835' (length=6)
'status' => string '1' (length=1)
'timestamp' => string '1421745203' (length=10)
'type' => string 'image' (length=5)
'uuid' => string '59484070-9a95-42fb-8b2a-594e5d3a7483' (length=36)
'field_file_image_alt_text' =>
array (size=0)
empty
'field_file_image_title_text' =>
array (size=0)
empty
'rdf_mapping' =>
array (size=0)
empty
'metadata' =>
array (size=2)
'height' => int 500
'width' => int 400
'alt' => string '' (length=0)
'title' => string '' (length=0)
'width' => string '400' (length=3)
'height' => string '500' (length=3)
我需要那个:
'#theme' => string 'picture_formatter' (length=17)
'#attached' =>
array (size=1)
'library' =>
array (size=3)
0 =>
array (size=2)
0 => string 'picture' (length=7)
1 => string 'picturefill_head' (length=16)
1 =>
array (size=2)
0 => string 'picture' (length=7)
1 => string 'picturefill' (length=11)
2 =>
array (size=2)
0 => string 'picture' (length=7)
1 => string 'picture.ajax' (length=12)
'#item' =>
array (size=18)
'fid' => string '3023' (length=4)
'uid' => string '1' (length=1)
'filename' => string 'profile_picture.jpg' (length=19)
'uri' => string 'public://profile_picture.jpg' (length=28)
'filemime' => string 'image/jpeg' (length=10)
'filesize' => string '325835' (length=6)
'status' => string '1' (length=1)
'timestamp' => string '1421745203' (length=10)
'type' => string 'image' (length=5)
'uuid' => string '59484070-9a95-42fb-8b2a-594e5d3a7483' (length=36)
'field_file_image_alt_text' =>
array (size=0)
empty
'field_file_image_title_text' =>
array (size=0)
empty
'rdf_mapping' =>
array (size=0)
empty
'metadata' =>
array (size=2)
'height' => int 500
'width' => int 400
'alt' => string '' (length=0)
'title' => string '' (length=0)
'width' => string '400' (length=3)
'height' => string '500' (length=3)
'#image_style' => string 'large_custom_user_mobile_1x' (length=27)
'#breakpoints' =>
array (size=5)
'custom.user.ultra_wide' =>
array (size=1)
'1x' =>
array (size=2)
'mapping_type' => string 'image_style' (length=11)
'image_style' => string 'large_custom_user_ultra_wide_1x' (length=31)
'custom.user.wide' =>
array (size=1)
'1x' =>
array (size=2)
'mapping_type' => string 'image_style' (length=11)
'image_style' => string 'large_custom_user_wide_1x' (length=25)
'custom.user.normal' =>
array (size=1)
'1x' =>
array (size=2)
'mapping_type' => string 'image_style' (length=11)
'image_style' => string 'large_custom_user_normal_1x' (length=27)
'custom.user.narrow' =>
array (size=1)
'1x' =>
array (size=2)
'mapping_type' => string 'image_style' (length=11)
'image_style' => string 'large_custom_user_narrow_1x' (length=27)
'custom.user.mobile' =>
array (size=1)
'1x' =>
array (size=2)
'mapping_type' => string 'image_style' (length=11)
'image_style' => string 'large_custom_user_mobile_1x' (length=27)
'#path' => string '' (length=0)
'#colorbox_group' =>
array (size=0)
empty
'#colorbox_image_style' => string '' (length=0)
所以问题是如何准备领域。
谢谢!
答案 0 :(得分:3)
我认为你要搜索的是field_view_field()。此函数将在内部hook_field_formatter_view()调用。图片模块implements this hook,根据$display
参数,它将在内部调用所提供的显示功能之一。
根据您请求的所需输出,您应该将picture
作为显示参数传递,以便调用似乎返回相应可渲染数组的picture_field_formatter_picture_view()。