B
B
Browar2018-03-26 17:16:16
Programming
Browar, 2018-03-26 17:16:16

Removing a part from a PHP link. How to be?

There are conflicts with the template on a multilingual site. The site switches to another language according to the principle: site.ru -> site.ru/en/ As I understand it, the get_header_image function tries to get links to the image, but does not receive a response, because the picture is on the site.ru version, and the function requests from site.ru/en/ which does not allow access to site.ru. Because of what, site.ru/en/ does not show the header image, when it is on site.ru. Sorry for the nonsense, but I think it is.
And if I think correctly, then the question arises: How can I correctly write preg_replace so that /en/ is removed for get_header_image . There are also other languages ​​/en/, /de/, /be/

<?php
        $header_img = esc_url( get_header_image() );

        if( !empty( $header_img ) ){
            echo '<div class="valign-cell-wrapper scene-wrapper">';
            echo '<div class="valign-cell">';

            echo '<div class="parallax" style="background-image: url(' . esc_url( $header_img ) . ');">';
            echo '<img src="' . esc_url( $header_img ) . '" alt="' . __( 'Header Image') . ' - ' . esc_attr( $title_label ) . '" class="parallax-image"/>';
            echo '</div>';

            echo '</div>';
            echo '</div>';
        }
    ?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2018-03-26
@webinar

Not the right approach, as I understand it, because of this, there will be problems with any files. So the approach should be either:
set up htaccess so that it would give existing files right away and not go into php at all,
or:
find the internationalization code and exclude all urls c .jpg, .png, .css, .js, etc.
or:
create the en directory and make a symlink to the root
Because your method will solve the problem in only 1 template

T
ThunderCat, 2018-03-26
@ThunderCat

see .htaccess, most likely it does not contain exceptions for rewriting on image files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question