PHP: Slumpa bild

[fusion_builder_container hundred_percent=”no” equal_height_columns=”no” menu_anchor=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” background_color=”” background_image=”” background_position=”center center” background_repeat=”no-repeat” fade=”no” background_parallax=”none” parallax_speed=”0.3″ video_mp4=”” video_webm=”” video_ogv=”” video_url=”” video_aspect_ratio=”16:9″ video_loop=”yes” video_mute=”yes” overlay_color=”” video_preview_image=”” border_color=”” border_style=”solid” padding_top=”” padding_bottom=”” padding_left=”” padding_right=”” type=”legacy”][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_color=”” border_style=”solid” border_position=”all” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” center_content=”no” last=”true” min_height=”” hover_type=”none” link=”” border_sizes_top=”” border_sizes_bottom=”” border_sizes_left=”” border_sizes_right=”” first=”true”][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”” rule_size=”” rule_color=”” hue=”” saturation=”” lightness=”” alpha=”” content_alignment_medium=”” content_alignment_small=”” content_alignment=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” sticky_display=”normal,sticky” class=”” id=”” margin_top=”” margin_right=”” margin_bottom=”” margin_left=”” fusion_font_family_text_font=”” fusion_font_variant_text_font=”” font_size=”” line_height=”” letter_spacing=”” text_transform=”” text_color=”” animation_type=”” animation_direction=”left” animation_color=”” animation_speed=”0.3″ animation_delay=”0″ animation_offset=”” logics=””]Det finns ex antal sätt att slumpa fram en bild på en sida.
Här är ett sätt som jag brukar använda =)
Vi skapar en funktion som vi döper till slumpaBild

Därefter skapar vi en Array när vi lägger bilderna.

Efter det är det bara att anropa vår funktion där vi vill ha den.

[/fusion_text][fusion_code]PCEtLT8gcGhwIGVjaG8gJzxpbWcgc3JjPSInLnNsdW1wYUJpbGQoJG1pbmFfYmlsZGVyKS4nIiBhbHQ9IlNsdW1wYWQgYmlsZCIgPj8gLS0+[/fusion_code][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]


Kommentarer

Lämna ett svar

This website uses cookies. By continuing to use this site, you accept our use of cookies. 

Upptäck mer från Malvack.net

Prenumerera nu för att fortsätta läsa och få tillgång till hela arkivet.

Fortsätt läsa