쿼리 라이브러리
쿼리 라이브러리게시물의 모든 이미지 소스에서 "http"를 "https"로 교체하기

게시물의 모든 이미지 소스에서 "http"를 "https"로 교체하기

이 쿼리는 게시물의 HTML에 있는 이미지 소스 내의 모든 http URL을 https로 교체합니다.

query GetPostData($postId: ID!) {
  post(by: { id: $postId }, status: any) {
    id
    rawContent
    adaptedRawContent: _strRegexReplace(
      searchRegex: "/<img(\\s+)?([^>]*?\\s+?)?src=([\"'])http:\\/\\/(.*?)/"
      replaceWith: "<img$1$2src=$3https://$4$3"
      in: $__rawContent
    )
      @export(as: "adaptedRawContent")
  }
}
 
mutation ReplaceHttpWithHttpsInImageSources($postId: ID!)
  @depends(on: "GetPostData")
{
  updatePost(input: {
    id: $postId,
    contentAs: { html: $adaptedRawContent },
  }) {
    status
    errors {
      __typename
      ...on ErrorPayload {
        message
      }
    }
    post {
      id
      title
      rawContent
    }
  }
}