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

Fixathon: Add image alt text #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions contribution-license-agreement.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I hereby agree to Spryker's Contribution License Agreement in https://github.com/spryker/product-management/blob/d9ca3d5624ffcc3862aac94ceb3450fae8eb2421/CONTRIBUTING.md
2 changes: 2 additions & 0 deletions data/translation/Zed/de_DE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,5 @@ Price,Preis
select,auswählen
"Product name",Produktname
Types,Typen
Alt text small,Alt-Text klein
Alt text large,Alt-Text groß
2 changes: 2 additions & 0 deletions data/translation/Zed/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,5 @@ Price,Price
select,select
"Product name","Product name"
Types,Types
Alt text small,Alt text small
Alt text large,Alt text large
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ class ImageCollectionForm extends AbstractSubForm
*/
public const FIELD_FK_IMAGE_SET_ID = 'fk_image_set_id';

/**
* @var string
*/
public const FIELD_ALT_TEXT_SMALL = 'alt_text_small';

/**
* @var string
*/
public const FIELD_ALT_TEXT_LARGE = 'alt_text_large';

/**
* @var string
*/
Expand Down Expand Up @@ -120,7 +130,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->addImagePreviewField($builder, $options)
->addImageSmallField($builder, $options)
->addImageBigField($builder, $options)
->addSortOrderField($builder, $options);
->addSortOrderField($builder, $options)
->addAltTextSmallField($builder, $options)
->addAltTextLargeField($builder, $options);
}

/**
Expand Down Expand Up @@ -279,4 +291,50 @@ protected function addSortOrderField(FormBuilderInterface $builder, array $optio

return $this;
}

/**
* @param \Symfony\Component\Form\FormBuilderInterface $builder
* @param array<string, mixed> $options
*
* @return $this
*/
protected function addAltTextSmallField(FormBuilderInterface $builder, array $options)
{
$builder->add(static::FIELD_ALT_TEXT_SMALL, TextType::class, [
'required' => false,
'label' => 'Alt text small',
'constraints' => [
new Length([
'min' => 0,
'max' => 255,
]),
],
'sanitize_xss' => true,
]);

return $this;
}

/**
* @param \Symfony\Component\Form\FormBuilderInterface $builder
* @param array<string, mixed> $options
*
* @return $this
*/
protected function addAltTextLargeField(FormBuilderInterface $builder, array $options)
{
$builder->add(static::FIELD_ALT_TEXT_LARGE, TextType::class, [
'required' => false,
'label' => 'Alt text large',
'constraints' => [
new Length([
'min' => 0,
'max' => 255,
]),
],
'sanitize_xss' => true,
]);

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<div class="form-group">
{{ form_row(form.external_url_small) }}
</div>
<div class="form-group">
{{ form_row(form.alt_text_small) }}
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
Expand All @@ -27,6 +30,9 @@
<div class="form-group">
{{ form_row(form.external_url_large) }}
</div>
<div class="form-group">
{{ form_row(form.alt_text_large) }}
</div>
</div>
<div class="col-lg-12">
{% for child in form %}
Expand Down
Loading