Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
Randome background for elementor

I use Elementor pro in my site. I have big Background image in top of my homepage that I have many elements in that section. I want to have one random image from a group of images (can be in gallery or in folder). but i didn't fine any solution.

I tried any addon for elementor. elementor pro background slidet, the plus row background, and etc. but they only make a slides with default order and don't have random order. I also tried some slider plugin or elementor's slider addons (smart slider,...). but the elements that should be on the image (other than text and buttons) could not be added to them.

I tried some javascripts to do it (for example: https://element.how/elementor-slider-random/#comment-12854 and this: Random background image on refresh). but it didn't work.

I like to know there is any solution to use custom php code to elementor dynamic simple background image that apply all background setting?

is there any solution?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

protected function render() {
    $settings = $this->get_settings_for_display();

    $images = array_values( $settings['carousel'] ?? [] );
    if ( ! $images ) {
        return;
    }
    $count = count( $images );
    $image = random_int( 0, ( $count - 1 ) );
    $image = $images[ $image ] ?? null;
    if ( ! $image ) {
        return;
    }

    $image_url = Group_Control_Image_Size::get_attachment_image_src( $image['id'], 'full', [ 'full_size' => 'full' ] );

    echo '<img class="' . $this->get_name() . '-image" src="' . esc_attr( $image_url ) . '" alt="' . esc_attr( Control_Media::get_image_alt( $image ) ) . '" />';
}

Elementor create a custom widget and follow the code. I hope your problem will be solved.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda