File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
libs/blog-bff/articles/api/src/lib Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
12
12
import { WPPostDetailsDto , WPPostDto } from './dtos' ;
13
13
import {
14
14
crayonCodeRewriter ,
15
+ modifyImages ,
15
16
modifyLinks ,
16
17
removeEmptyParagraphs ,
17
18
rewriteHTML ,
@@ -73,6 +74,7 @@ export const toArticle = (dto?: WPPostDetailsDto): Article => {
73
74
crayonCodeRewriter ,
74
75
removeEmptyParagraphs ,
75
76
modifyLinks ,
77
+ modifyImages ,
76
78
) ( $ ) ;
77
79
78
80
// add id to anchorTypes elements for anchor links
Original file line number Diff line number Diff line change @@ -102,3 +102,24 @@ export const modifyLinks: RewriteAdapter = ($) => {
102
102
}
103
103
} ) ;
104
104
} ;
105
+
106
+ /**
107
+ * Replaces image source to the new domain
108
+ * @param $
109
+ */
110
+ export const modifyImages : RewriteAdapter = ( $ ) => {
111
+ $ ( 'img' ) . each ( ( _ , element ) => {
112
+ const $element = $ ( element ) ;
113
+ const src = $element . attr ( 'src' ) ;
114
+
115
+ if ( src && src . startsWith ( 'https://angular.love/wp-content' ) ) {
116
+ $element . attr (
117
+ 'src' ,
118
+ src . replace (
119
+ 'https://angular.love/wp-content' ,
120
+ 'https://wp.angular.love/wp-content' ,
121
+ ) ,
122
+ ) ;
123
+ }
124
+ } ) ;
125
+ } ;
You can’t perform that action at this time.
0 commit comments