Skip to content

Background image inside buttons #429

@PippoGot

Description

@PippoGot

Please fill out these Check-boxes

  • I checked for existing similar feature requests
  • I have read the docs and checked that the feature I am requesting is not already implemented
  • My feature request consists of only one feature

Is your Feature Request related to a Problem or Annoyance?

No response

Describe the Feature you'd like

I know I may be repetitive (since I opened an issue the other day about a similar topic for this very reason) and I apologize for that, but I'll try again one last time and do my best to explain why I would REALLY LOVE this feature.

I am currently building MOCs for a "wiki" vault about a fantasy world and to better visualize them I was thinking about decorating the various buttons that brings to different pages with images/icons. However, aside the default obsidian icons the other options are not supported.

I know custom icons won't be ever supported and I can be ok with that, however, maybe an additional button type where you can add/change a custom background image from inside the codeblock may be easier to implement (I guess?).

I will paste some images of the result I'm looking for:

image buttons

In this specific case each button opens a different MOC, but I have plans to have other buttons to do more stuff inside those MOCs (such as automatic note creation and automation) and would like to style them similarly to keep the continuity.

Alternatives

I kind of managed to obtain similar results with css, but it's a nuisance to get the size right and (maybe becasue I'm a noob at css) I can't get it to change proportionally to the page size while keeping the image inside the button. Also, a unique css style can't be obtained for multiple buttons with different images, but I'd have to make a style for each button and manually change in css the image also inputting the image size as the button size.

Another way I managed to obtain results is to simply use images embeds and use them as links to open the notes (this is the case of the image I provided), but this is not intuitive as the images don't behave as buttons (when hovering they don't look selected and the cursor doesn't change). Furthermore this alternative prevents me from adding functionality to the "buttons" since all I can do is link notes.

Additional Context

So, to sum up what I'd like to request is a new button type (or just manage it however you feel like it's most appropriate) with an additional field to set a background image (either png, jpg or svg) in a button, with maybe also a "scale" property to change the size. Something like this:

label: This is a button
background: "/path/to/local/image.png or .svg" (either background color or image or both)
image-scale: [see below (1)]
hidden: false
class: whatever
tooltip: "whatever"
id: whatever
style: image (or what you feel most suitable)
actions: [whatever]

(1) css kind of values for scaling/sizing

  • size array [width, height]
  • scale: maintain aspect ratio of original image but shrinks or zooms the image
  • aspect ratio: redefine an aspect ratio and set one between width and height [width, ratio] or [ratio, height]
  • empty: keeps the size of the background image

I'm really interested in 4th option but thought since I'm here to throw some alternatives.

Not really important to have a detailed preview if that would be a problem.

Thanks for your attention, I really hope I didn't bother you too much. Thanks for the amazing contribution to the community.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions