diff --git a/x-pack/legacy/plugins/integrations_manager/public/hooks/use_links.tsx b/x-pack/legacy/plugins/integrations_manager/public/hooks/use_links.tsx
index 665944e98d6ca..e951b6827b1d7 100644
--- a/x-pack/legacy/plugins/integrations_manager/public/hooks/use_links.tsx
+++ b/x-pack/legacy/plugins/integrations_manager/public/hooks/use_links.tsx
@@ -6,7 +6,7 @@
import { generatePath } from 'react-router-dom';
import { PLUGIN } from '../../common/constants';
-import { API_ROOT } from '../../common/routes';
+import { getFilePath, getInfoPath } from '../../common/routes';
import { patterns } from '../routes';
import { useCore } from '.';
import { DetailViewPanelName } from '..';
@@ -19,6 +19,9 @@ interface DetailParams {
panel?: DetailViewPanelName;
}
+const removeRelativePath = (relativePath: string): string =>
+ new URL(relativePath, 'http://example.com').pathname;
+
function addBasePath(path: string) {
const { http } = useCore();
return http.basePath.prepend(path);
@@ -32,7 +35,21 @@ function appRoot(path: string) {
export function useLinks() {
return {
toAssets: (path: string) => addBasePath(`/plugins/${PLUGIN.ID}/assets/${path}`),
- toImage: (path: string) => addBasePath(`${API_ROOT}${path}`),
+ toImage: (path: string) => addBasePath(getFilePath(path)),
+ toRelativeImage: ({
+ path,
+ packageName,
+ version,
+ }: {
+ path: string;
+ packageName: string;
+ version: string;
+ }) => {
+ const imagePath = removeRelativePath(path);
+ const pkgkey = `${packageName}-${version}`;
+ const filePath = `${getInfoPath(pkgkey)}/${imagePath}`;
+ return addBasePath(filePath);
+ },
toListView: () => appRoot(patterns.LIST_VIEW),
toDetailView: ({ name, version, panel }: DetailParams) => {
// panel is optional, but `generatePath` won't accept `path: undefined`
diff --git a/x-pack/legacy/plugins/integrations_manager/public/screens/detail/markdown_renderers.tsx b/x-pack/legacy/plugins/integrations_manager/public/screens/detail/markdown_renderers.tsx
index 2633040a677d7..8f154789de31f 100644
--- a/x-pack/legacy/plugins/integrations_manager/public/screens/detail/markdown_renderers.tsx
+++ b/x-pack/legacy/plugins/integrations_manager/public/screens/detail/markdown_renderers.tsx
@@ -13,7 +13,6 @@ import {
EuiLink,
} from '@elastic/eui';
import React from 'react';
-// import { useLinks } from '../../hooks';
/** prevents links to the new pages from accessing `window.opener` */
const REL_NOOPENER = 'noopener';
@@ -24,15 +23,6 @@ const REL_NOFOLLOW = 'nofollow';
/** prevents the browser from sending the current address as referrer via the Referer HTTP header */
const REL_NOREFERRER = 'noreferrer';
-/*
-// skipping images for now
-const WrappedEuiImage = ({alt, src, title}: any) => {
- const { toImage } = useLinks();
- const url = toImage(src);
- return