Skip to content

Commit

Permalink
chore: media library to expose path and URL
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev committed Jan 31, 2025
1 parent 3a44e99 commit bc5e53c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/components/avo/media_library/list_item_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def data
component: component_name,
blob_id: blob.id,
media_library_blob_param: blob.as_json,
media_library_path_param: helpers.main_app.url_for(blob),
media_library_path_param: helpers.main_app.rails_blob_path(blob),
media_library_url_param: helpers.main_app.url_for(blob),
media_library_attaching_param: @attaching,
media_library_multiple_param: @multiple,
media_library_selected_item: params[:controller_selector],
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/js/controllers/media_library_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class extends Controller {
insertAttachments(attachments, event) {
// show an error if the controller is not found
if (!this.otherController) {
console.error('[Avo->] The Media Library failed to find any field outlets to inject the asset.')
console.error(`[Avo->] The Media Library failed to find any field outlets to inject the asset. Tried selector: ${this.controllerSelectorValue} and name: ${this.controllerNameValue}`)

return
}
Expand All @@ -82,7 +82,8 @@ export default class extends Controller {
#extractMetadataFromItem(item) {
const blob = JSON.parse(item.dataset.mediaLibraryBlobParam)
const path = item.dataset.mediaLibraryPathParam
const url = item.dataset.mediaLibraryUrlParam

return { blob, path }
return { blob, path, url }
}
}

0 comments on commit bc5e53c

Please sign in to comment.