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

TMS-1061: Change hero video-field from URL to File #517

Merged
merged 3 commits into from
Sep 11, 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
2 changes: 2 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

- TMS-1061: Change hero video-field from URL to File, since the URL wasn't working

## [1.58.1] - 2024-09-03

- TMS-1062: Increase menu-dropdown button size
Expand Down
21 changes: 11 additions & 10 deletions lib/ACF/Fields/HeroFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function sub_fields() : array {
'instructions' => '',
],
'video' => [
'label' => 'Videon URL',
'label' => 'Videotiedosto',
'instructions' => '',
],
'title' => [
Expand Down Expand Up @@ -74,40 +74,41 @@ protected function sub_fields() : array {
$key = $this->get_key();

$image_field = ( new Field\Image( $strings['image']['label'] ) )
->set_key( "${key}_image" )
->set_key( "{$key}_image" )
->set_name( 'image' )
->set_return_format( 'id' )
->set_wrapper_width( 50 )
->set_instructions( $strings['image']['instructions'] );

$video_field = ( new Field\URL( $strings['video']['label'] ) )
->set_key( "${key}_video" )
->set_name( 'video' )
$video_field = ( new Field\File( $strings['video']['label'] ) )
->set_key( "{$key}_video_file" )
->set_name( 'video_file' )
->set_mime_types( [ 'mp4' ] )
->set_wrapper_width( 50 )
->set_instructions( $strings['video']['instructions'] );

$title_field = ( new Field\Text( $strings['title']['label'] ) )
->set_key( "${key}_title" )
->set_key( "{$key}_title" )
->set_name( 'title' )
->set_wrapper_width( 50 )
->set_instructions( $strings['title']['instructions'] );

$description_field = ( new Field\Textarea( $strings['description']['label'] ) )
->set_key( "${key}_description" )
->set_key( "{$key}_description" )
->set_name( 'description' )
->set_rows( 4 )
->set_new_lines( 'wpautop' )
->set_wrapper_width( 50 )
->set_instructions( $strings['description']['instructions'] );

$link_field = ( new Field\Link( $strings['link']['label'] ) )
->set_key( "${key}_link" )
->set_key( "{$key}_link" )
->set_name( 'link' )
->set_wrapper_width( 40 )
->set_instructions( $strings['link']['instructions'] );

$align_field = ( new Field\Select( $strings['align']['label'] ) )
->set_key( "${key}_align" )
->set_key( "{$key}_align" )
->set_name( 'align' )
->set_choices( [
'left' => 'Vasen',
Expand All @@ -119,7 +120,7 @@ protected function sub_fields() : array {
->set_instructions( $strings['align']['instructions'] );

$use_box_field = ( new Field\TrueFalse( $strings['use_box']['label'] ) )
->set_key( "${key}_use_box" )
->set_key( "{$key}_use_box" )
->set_name( 'use_box' )
->use_ui()
->set_wrapper_width( 30 )
Expand Down
6 changes: 3 additions & 3 deletions partials/layouts/layout-hero.dust
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<div class="overlay overlay--dark-50"></div>
{/use_overlay}

{?video}
{?video_file}
<div class="is-overlay is-clipped" aria-hidden="true" tabindex="-1">
<video src="{video}" class="hero__video is-hidden" loop muted playsinline></video>
<video src="{video_file.url|url}" class="hero__video is-hidden" loop muted playsinline></video>

<button class="hero__control hero__control--play" aria-label="{Strings.s.video.play|attr}">
{>"ui/icon" icon="play" class="icon--xxxlarge" /}
Expand All @@ -16,7 +16,7 @@
{>"ui/icon" icon="pause" class="icon--xxxlarge" /}
</button>
</div>
{/video}
{/video_file}

<div class="hero__inner">
<div class="container">
Expand Down
Loading