Query-bibliotheek
Query-bibliotheekVervang "http" door "https" in alle afbeeldingsbronnen in een bericht

Vervang "http" door "https" in alle afbeeldingsbronnen in een bericht

Deze query vervangt alle http URL's door https in de afbeeldingsbronnen van de HTML van het bericht.

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
    }
  }
}