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

Pages should do recursive search for image files #2702

Closed
AnnMarieW opened this issue Nov 27, 2023 · 2 comments
Closed

Pages should do recursive search for image files #2702

AnnMarieW opened this issue Nov 27, 2023 · 2 comments

Comments

@AnnMarieW
Copy link
Collaborator

When creating meta tags, Pages only searches the root of the assets folder for image files. It would be better to do a recursive search since it's common to use folders within /assets in larger projects.

This would still be consistent with the docs which states:

The image value must be the name of a file inside the assets folder.

If you don't specify image, Pages checks for an image that meets one of these criteria (in order) and uses the first one it finds....

Currently it's necessary to specify the image file name ie image="images/app.png" when using subfolder in /assets. This change would make that step unnecessary.

I could do the PR to fix this if you like 🙂

@alexcjohnson
Copy link
Collaborator

For completeness here's the full docstring you're referring to:

dash/dash/_pages.py

Lines 246 to 253 in f70b3db

- `image`:
The meta description image used by social media platforms.
If not supplied, then it looks for the following images in `assets/`:
- A page specific image: `assets/<module>.<extension>` is used, e.g. `assets/weekly_analytics.png`
- A generic app image at `assets/app.<extension>`
- A logo at `assets/logo.<extension>`
When inferring the image file, it will look for the following extensions:
APNG, AVIF, GIF, JPEG, JPG, PNG, SVG, WebP.

Walking the whole assets dir is certainly easy for users, I'm just trying to figure out how likely it is it'll lead to ambiguity or unintended effects... like since app.<extension> and logo.<extension> are pretty generic, what if deep in some subdir there's an app.jpg that you didn't really mean to use for this purpose? For example you add a folder of a million icons that you want to use a couple of in your layout, like bootstrap icons https://icons.getbootstrap.com/icons/app/

I don't know how many people would hit that, but it could be very confusing if it did happen. As a safer (but less user-friendly) alternative we could make a global setting "look in this assets subfolder for pages images" perhaps with an option like "*" to walk the whole dir?

@AnnMarieW
Copy link
Collaborator Author

I can see how this could lead to some unexpected results. It’s certainly possible to limit the search to certain folders, but I think it would add complexity rather than reduce it — which was the goal.

It’s probably best to close this issue, and it could be reopened later if people think it’s worthwhile.

@AnnMarieW AnnMarieW closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants