Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No text but images #126

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions lib/teksttv.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,31 +134,30 @@ private function get_article_slides($block)
}
}

// Skip if this post isn't for TekstTV
$kabelkrant_content = get_field('post_kabelkrant_content', get_the_ID());
if (empty($kabelkrant_content)) {
continue;
}

// Get the primary category image for the post
$slide_image = $this->get_primary_category_image(get_the_ID());

// Split content by pages using "---" as a delimiter
$pages = preg_split('/\n*-{3,}\n*/', $kabelkrant_content);

// Generate a slide for each page of content
foreach ($pages as $index => $page_content) {
$slides[] = [
'type' => 'text',
'duration' => 25000, // 25 seconds per slide, adjust as needed
'title' => get_the_title(),
'body' => wpautop(trim($page_content)),
'image' => !empty($slide_image) ? $slide_image : null,
];
// Check for content or extra images
$kabelkrant_content = get_field('post_kabelkrant_content', get_the_ID());
$extra_images = get_field('post_kabelkrant_extra_afbeeldingen', get_the_ID());

if (!empty($kabelkrant_content)) {
// Split content by pages using "---" as a delimiter
$pages = preg_split('/\n*-{3,}\n*/', $kabelkrant_content);

// Generate a slide for each page of content
foreach ($pages as $index => $page_content) {
$slides[] = [
'type' => 'text',
'duration' => 20000, // 20 seconds per slide, adjust as needed
'title' => get_the_title(),
'body' => wpautop(trim($page_content)),
'image' => !empty($slide_image) ? $slide_image : null,
];
}
}

// Add extra images (if any) as separate slides
$extra_images = get_field('post_kabelkrant_extra_afbeeldingen', get_the_ID());
// Add extra images (if any) as separate slides, even if content is empty
if (!empty($extra_images)) {
foreach ($extra_images as $image) {
if (!empty($image['url'])) {
Expand Down Expand Up @@ -190,7 +189,7 @@ private function get_primary_category_image($post_id)
}
}

// We fall back to post thumbnail if no primary category image
// Fall back to post thumbnail if no primary category image
return get_the_post_thumbnail_url($post_id, 'large');
}

Expand Down
5 changes: 3 additions & 2 deletions streekomroep-acf-json/group_5f21a05a18b57.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"aria-label": "",
"type": "textarea",
"instructions": "",
"required": 1,
"required": 0,
"conditional_logic": [
[
{
Expand All @@ -66,6 +66,7 @@
},
"default_value": "",
"maxlength": "",
"allow_in_bindings": 1,
"rows": 7,
"placeholder": "Vul de versie voor op teksttv in",
"new_lines": ""
Expand Down Expand Up @@ -259,5 +260,5 @@
"active": true,
"description": "",
"show_in_rest": 0,
"modified": 1728769658
"modified": 1729879906
}
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
* Theme Name: Streekomroep
* Description: This is a WordPress theme made for Streekomroep ZuidWest in the Netherlands. It's made using Timber and Tailwind CSS and provides functionality for regional news, radio and television broadcasts.
* Author: Streekomroep ZuidWest
* Version: 1.10.0-beta6
* Version: 1.10.0-beta7
*/