Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

[MAINTAIN-151] added frameborder to embedded videos in all Open Y themes #2526

Closed
wants to merge 2 commits into from
Closed

Conversation

aleevas
Copy link
Contributor

@aleevas aleevas commented Aug 2, 2021

Original Issue, this PR is going to fix: MAINTAIN-151

The fix should add the border to all embedded video entities
MAINTAIN-151BorderInEmbededVideo

Steps for review

  • log as admin

  • go to edit node (blog post foe example)

  • to add a new External video entity
    MAINTAIN-151AddEmbededVideo

  • save node and verify that iframe has border=1
    MAINTAIN-151BorderInEmbededVideo

  • verify that for all themes

General checks

Thank you for your contribution!

@gundevel
Copy link
Collaborator

gundevel commented Aug 2, 2021

Can one of the admins verify this patch? Use "o+k to test" or ''t+est this please" for manual build execution.

@podarok
Copy link
Contributor

podarok commented Aug 2, 2021

ok to test

@gundevel
Copy link
Collaborator

gundevel commented Aug 2, 2021

Build comment file:

Check Open Y Installation Wizard at http://install.openy.cibox.tools/build3308/install.php


Test PASSed.
Refer to this link for build results (access rights to CI server needed):
http://openy.cibox.tools:8080/job/PR_BUILDER_COMPOSER/3308/

@gundevel
Copy link
Collaborator

gundevel commented Aug 2, 2021

Open Y Upgrade Path site check installed at http://upgrade.openy.cibox.tools/build3308/

function openy_carnation_preprocess_video_embed_iframe(array &$variables) {
if ($attr = $variables['attributes']) {
/** @var \Drupal\Core\Template\Attribute $attr */
$attr->setAttribute('frameborder', 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if there is already frameborder, but not 1. It'll be overridden by this code.
Let's be less generic
If no frameborder - set it to 1
if frameborder = 0, or any other number - skip it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@podarok sorry, but I don't understand that logic.
The frameborder attrubute by default has value 0, for all providers. And if we will skip it for frameborder = 0 , then our code doen't work at all
image (18)

In what case we can have another value for that attribute?
cc @hamrant

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aleevas as a content manager I can set frameborder explicitly to 0. your code would break it and reset to 1
We need to check if frameborder is set to any value before setting it to 1 in our case.
If it is set to any value - we must avoid of setting to 1

Copy link
Contributor Author

@aleevas aleevas Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@podarok
Sorry, but I can't find any ability for content manager to change value for farmeborder attribute.
As you can see on screenshot above, we have settings only for the width and the height attribute, the frameborder attribute has a hardcoded value = 0. And this is actual in any other places where mentioning the framborder attribute even in others modules.
Why we expect the border=1 as it written in jira issue?
Please help me to understand what I missed here
cc @hamrant

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to underestimate content managers
They can edit HTML in WYSIWYG in order to set 0 for frameborder. @aleevas

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@podarok
thanks for you time.
I've added a new commit with logic that you presented in first comment of this thread.
Please check if I got you right
cc @hamrant

@gundevel
Copy link
Collaborator

gundevel commented Aug 3, 2021

Build comment file:

Check Open Y Installation Wizard at http://install.openy.cibox.tools/build3309/install.php


Test PASSed.
Refer to this link for build results (access rights to CI server needed):
http://openy.cibox.tools:8080/job/PR_BUILDER_COMPOSER/3309/

@gundevel
Copy link
Collaborator

gundevel commented Aug 3, 2021

Open Y Upgrade Path site check installed at http://upgrade.openy.cibox.tools/build3309/

@podarok podarok marked this pull request as ready for review August 3, 2021 10:44
@podarok
Copy link
Contributor

podarok commented Aug 3, 2021

image
Seems like we need to remove default value 0 in order for our logic to start working properly @aleevas
Check http://upgrade.openy.cibox.tools/build3309/demo-landing

@podarok
Copy link
Contributor

podarok commented Aug 3, 2021

The idea is to have default 1, but do not break other options if set manually @aleevas @hamrant

if (!$attr || !$attr instanceof Attribute) {
return;
}
if (!$attr->hasAttribute('frameborder')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this condition not works... There is no border on the http://upgrade.openy.cibox.tools/build3309/about.

Screenshot from 2021-08-03 13-55-17

So on this preprocess level, we always have value for frameborder.

  1. frameborder attribute hardcoded in the renderEmbedCode method:
  • video_embed_field/src/Plugin/video_embed_field/Provider/Vimeo.php
  • video_embed_field/src/Plugin/video_embed_field/Provider/YouTube.php
  • video_embed_field/src/Plugin/video_embed_field/Provider/YouTubePlaylist.php
  1. Element defined in the video_embed_field/src/Element/VideoEmbedIFrame.php we have there getInfo() method and '#pre_render' with preRenderInlineFrameEmbed function.

Proposed solution: add a custom method to the '#pre_render' array after preRenderInlineFrameEmbed function and set frameborder attribute to 1 inside this function. Element info can be altered with hook_element_info_alter, see core/lib/Drupal/Core/Render/ElementInfoManager.php:

    // Allow modules to alter the element type defaults.
    $this->moduleHandler->alter('element_info', $info);
    $this->themeManager->alter('element_info', $info);

In this case, frameborder can be changed later in preprocess functions or in a different place.

I think we can move this to https://github.com/open-y-subprojects/openy_features/tree/main/openy_media/modules/openy_media_video.

cc @aleevas @podarok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hamrant thank you for your time and great advise.
I've made a PR to openy-features github open-y-subprojects/openy_features#8
I think this PR we can close
cc @podarok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@podarok this PR looks ok for me - open-y-subprojects/openy_features#8

Feel free to merge and release a new version of openy_features.

@podarok
Copy link
Contributor

podarok commented Aug 3, 2021

@aleevas https://github.com/open-y-subprojects/openy_features/releases/tag/1.5

Feel free to create PR to current repo with this release as a baseline in composer.json
/cc @hamrant

@aleevas
Copy link
Contributor Author

aleevas commented Aug 3, 2021

@aleevas https://github.com/open-y-subprojects/openy_features/releases/tag/1.5

Feel free to create PR to current repo with this release as a baseline in composer.json
/cc @hamrant

@podarok I've create a new PR with latest version of opney_features module PR #2529
Please check
cc @hamrant

@hamrant
Copy link
Contributor

hamrant commented Aug 3, 2021

Fixed in #2529

@hamrant hamrant closed this Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants