diff --git a/content-advertiser.php b/content-advertiser.php index b9c1e16..3fc827d 100644 --- a/content-advertiser.php +++ b/content-advertiser.php @@ -47,9 +47,10 @@ $extensionToClassMap = [ diff --git a/content-post.php b/content-post.php index e968dfa..14fa61d 100644 --- a/content-post.php +++ b/content-post.php @@ -5,7 +5,7 @@ $class = $full_width ? 'article-item article-item--lg' : 'article-item'; ?>
- +
diff --git a/frontend/src/styles/pages/main.css b/frontend/src/styles/pages/main.css index a54457f..28ef713 100644 --- a/frontend/src/styles/pages/main.css +++ b/frontend/src/styles/pages/main.css @@ -14,22 +14,39 @@ } .content-right { - grid-area: right; + grid-area: right; } .content-right__link-item { font-weight: 500; } -<<<<<<< HEAD - -======= ->>>>>>> 8c3c602de751cb17721311afac451c4109c6924d ul.wp-block-list li{ display: block; padding: 4px 0; } +.about p { + margin-bottom: 1em; +} + +.content-middle picture, +.content-middle img, +.content-middle picture img { + max-width: 100%; + height: auto; + display: block; +} + +.article-single IMG{ + max-width: 100%; +} + +.image-caption{ + margin: 12px 0; + text-align: center; +} + @media (max-width: 1439px) { .content { grid-template-columns: 36.4rem 1fr; @@ -206,7 +223,7 @@ ul.wp-block-list li{ .banner-left { margin: 2.5rem auto 0; - height: 40rem; + /*height: 40rem;*/ width: 24rem; } diff --git a/functions.php b/functions.php index 054deb2..3a9c0ad 100644 --- a/functions.php +++ b/functions.php @@ -1180,5 +1180,79 @@ function restrict_author_publish_posts( $data ) { } add_filter( 'wp_insert_post_data', 'restrict_author_publish_posts' ); +function replace_first_figure_in_content($content) { + + global $post; + + if (!isset($post->ID)) { + return $content; + } + + $startPos = strpos($content, ' не найдено, возвращаем исходный контент + } + + $endPos = strpos($content, '', $startPos); + if ($endPos === false) { + return $content; // Если не найдено, возвращаем исходный контент + } + + // Рассчитываем длину части, которую нужно заменить + $endPos += strlen(''); // Двигаем указатель на конец тега + $figureHtml = substr($content, $startPos, $endPos - $startPos); + + + // Генерируем HTML изображения + $replacement = render_webp_picture_by_post($post->ID); + + // Ищем
внутри исходного фрагмента + $caption = ''; + if (preg_match('/(.*?)<\/figcaption>/is', $content, $caption_match)) { + $caption = '
'.$caption_match[1].'
'; // только содержимое + } + + $replacement .= $caption; + + // Заменяем найденный кусок на новый HTML + $newContent = substr_replace($content, $replacement, $startPos, $endPos - $startPos); + + + return $newContent; + + + // Ищем первое
...
+ if (preg_match('/.*?<\/figure>/is', $content, $match)) { + $original_figure = $match[0]; + + // Извлекаем
(если есть) + $caption = ''; + if (preg_match('/(.*?)<\/figcaption>/is', $original_figure, $caption_match)) { + $caption = $caption_match[1]; // только содержимое + } + + // Генерируем HTML изображения + $replacement = render_webp_picture_by_post($post->ID); + + // Добавляем подпись, если есть + if (!empty($caption)) { + $replacement .= '
' . esc_html($caption) . '
'; + } + + // Заменяем первое вхождение
...
на $replacement + $content = preg_replace('/.*?<\/figure>/is', $replacement, $content, 1); + } + + return $content; +} + + + + + + + + + diff --git a/header.php b/header.php index 3d33af3..b87b5f2 100644 --- a/header.php +++ b/header.php @@ -51,25 +51,14 @@ height="0" width="0" style="display:none;visibility:hidden"> >
- - - - - - - - - - - + + + +
diff --git a/page-for-advertisers.php b/page-for-advertisers.php index 1f4b14e..1d16373 100644 --- a/page-for-advertisers.php +++ b/page-for-advertisers.php @@ -29,7 +29,7 @@ $advertisers = new WP_Query([