Drupal 8 - How to hide help link About text formats and text format guidelines
Problem In drupal textarea field, it was always a pain to see the two links…
September 04, 2017
I use drupal-7 in my website. I used to write articles and put images in that from google or from free image sources. Initially, I usually put image urls from their website only. i.e. I have img tag on my website, and source of image as external url of image from their website.
Image tags (example image tag):
Now, manytimes, external sources removed their images, and my website/page left with no image, which is not a good impression for my users. This article is to find those articles/blogs which have this issue.
<h2>Code</h2>
```php
/**
* See if a drupal node has images within my domain or not
**/
function requireModification($nid) {
$nd = node_load($nid);
//read body of node
$body = $nd->body['und'][0]['value'];
$doc = new DOMDocument();
$doc->loadHTML($body);
//fetch all images in body of node
$tags = $doc->getElementsByTagName('img');
$imgArr = array();
foreach ($tags as $tag) {
//read src tag, source of image
$imgSrc = $tag->getAttribute('src');
//checking if image path is an http path and not in my domain
if ((strpos($imgSrc, 'http') === 0) && (strpos($imgSrc, 'https://s3.amazonaws.com/images.MYDOMAIN.com') !== 0)) {
return true;
}
}
return false;
}
//My node type name
$node_type = "article";
$result = db_query("SELECT nid FROM node WHERE type = :nodeType ", array(':nodeType'=>$node_type));
$nids = array();
foreach ($result as $obj) {
if (requireModification($obj->nid) === true) {
$nids[] = $obj->nid;
}
}
//printing node ids, which have images apart from my domain
print_r($nids);
Problem In drupal textarea field, it was always a pain to see the two links…
One of the biggest task while writing article or blog is to have right set of…
In previous article: Effective Git Branching Strategy, I discussed Git branching…
Each jar file has a manifest file in META_INF/MANIFEST.MF I have to read each…
Problem Statement I developed a simple ReactJS application where I have used…
Introduction In our previous post, where we saw How to configure comments module…
In this post, we will see some of the frequently used concepts/vocabulary in…
System design interview is pretty common these days, specially if you are having…
Introduction You are given an array of integers with size N, and a number K…
Graph Topological Sorting This is a well known problem in graph world…
Problem Statement Given a Binary tree, print out nodes in level order traversal…
Problem Statement Given an array nums of n integers and an integer target, are…