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

画像ブロックの丸抜きスタイルを正方形でない画像でも正円に切り抜くようにしたい #513

Closed
miminari opened this issue May 18, 2021 · 8 comments

Comments

@miminari
Copy link
Contributor

miminari commented May 18, 2021

Trello からおひっこし
https://trello.com/c/29R7xTOv

要望、仕様:
画像ブロック(コア)の標準スタイルで正円を実現する。

実現方法

  1. CSSで object-fit: cover 追記と フロント側のJSによって正円化する。 △
     → 正円にするというスタイル変更のためだけにフロント側をJSでDOM操作するのは微妙。
  2. object-fitコンポーネントを作成、コアの画像ブロックとは別に新規にカスタムブロック化して実現する。 △
     → フロント側がきれいになるけれど、ユーザーに2つのブロックの違いを理解させる必要がある。開発工数がかかる。

現状、都度正円の画像を用意してもらえば実現出来るものではあること、コアのブロックの標準スタイルなのでいずれ手が入ることなどを鑑みると他に注力し方が良い気がします。

@miminari miminari changed the title 画像ブロックの丸抜きスタイルを正円にしたい 画像ブロックの丸抜きスタイルを正方形でない画像でも正円に切り抜くようにしたい May 24, 2021
@miminari
Copy link
Contributor Author

miminari commented May 24, 2021

e2e で画像ブロックでシェイプが丸抜きスタイルに指定されている時、
画像の横幅が指定されたら、heightがインラインスタイルで指定されるかどうかのテストを書く

@miminari
Copy link
Contributor Author

@kurudrive すみません、取り掛かる前に私が仕様を少し勘違いしていたのですが、検証の結果、
object-fitをコントロールするコンポーネントを作成し、コアのブロックとは別のブロック化することで実現はできるとは思います。
が、その場合は開発コストがかかりすぎるということとユーザーの使いやすさとして微妙だな、というのがあります。

また、ちょうどコアで
[Block Library - Post Featured Image]: Add basic dimension controls by ntsekouras · Pull Request #31634 · WordPress/gutenberg
アイキャッチ画像に対してobject-fitのコントロールを行うPRが動いていますので、たぶんこれがうまくいけばobject-fitのコントロールができるコンポーネントが出来ると思うのでこれを待ったほうが良い気がします。

@miminari
Copy link
Contributor Author

miminari commented May 26, 2021

figure.wp-block-image{
    --rounded-image-width: min(80vw, 300px);
    &.is-style-rounded {
        img {
            object-fit: cover;
            width: var(--rounded-image-width);
            height: var(--rounded-image-width);
        }
    }
}

みたいなTIPSをブログとかでシェアするだけで良い気もします。

@miminari
Copy link
Contributor Author

あとは、別にもうひとつ正円、というカスタムスタイルを追加してあげて、上記のスタイルみたいな感じを当てて提供すると、UI上で正円が分かるから喜ばれる気はします。

@miminari
Copy link
Contributor Author

miminari commented May 26, 2021

直前に書いた代替案が良い気がするので、これで実装してPR出してみます。object-fit control が出てくるまでの場繋ぎ的なスタイルだけど。

@miminari
Copy link
Contributor Author

miminari commented Jun 9, 2021

WordPress/gutenberg#31634
まだOPENしているので、5.8では入らないから続きをやります

@miminari
Copy link
Contributor Author

miminari commented Jun 9, 2021

@kurudrive @goutetsuguma 対応しかけて色々触ってたら、画像ブロックのクロップ機能で正円が作れるようになってました!のでこちら対応必要なし、ということでクローズします!

@miminari miminari closed this as completed Jun 9, 2021
@kurudrive
Copy link
Member

@miminari 了解でーす!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants