Skip to content

Commit

Permalink
Media - display file name
Browse files Browse the repository at this point in the history
Useful to copy and paste into the Visual Editor,
on the .image component
  • Loading branch information
leandrocp committed Oct 24, 2024
1 parent 4fc33c9 commit fdb3ba3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/beacon/live_admin/live/media_library_live/show_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ defmodule Beacon.LiveAdmin.MediaLibraryLive.ShowComponent do
socket
|> assign(assigns)
|> assign(:is_image?, MediaLibrary.is_image?(site, asset))
|> assign(:url, MediaLibrary.url_for(site, asset))
|> assign(:urls, urls_for(site, asset))

{:ok, socket}
end

defp urls_for(site, asset) do
site
|> MediaLibrary.urls_for(asset)
|> Enum.with_index()
urls =
site
|> MediaLibrary.urls_for(asset)
|> Enum.with_index(1)

[{{"name", asset.file_name}, 0} | urls]
end

@impl true
Expand All @@ -38,7 +40,7 @@ defmodule Beacon.LiveAdmin.MediaLibraryLive.ShowComponent do
<label class="block text-sm font-semibold leading-6 text-zinc-800 capitalize">
<%= key %>
</label>
<input type="text" id={"url-#{index}"} value={url} class="flex mt-2 block w-full rounded-lg text-zinc-900 focus:ring-0 sm:text-sm sm:leading-6" />
<input type="text" id={"url-#{index}"} value={url} readonly class="flex mt-2 block w-full rounded-lg text-zinc-900 focus:ring-0 sm:text-sm sm:leading-6" />
</div>
<div class="flex">
<button phx-click={JS.dispatch("beacon_admin:clipcopy", to: "#url-#{index}")}>
Expand Down

0 comments on commit fdb3ba3

Please sign in to comment.