Find width=" " in html and change its value

I need to be able to find the width and height value in a html string. Then after the width tag change the value between the first " and the second " to whatever I need it to be.

So basically I want to have control over an image size, even though its size is already set.

Is there a way I can find i in the number of “width” in string and set its parameters between the " and " to a different value. The values of the width and height change each time, so i cannot keep a specific look out for a specific size.

All help is much appreciated. Thank you

(edit)

The values look like so:

width="660" height="430"

1 Like

As the numeric values in the width and height vary (and thus vary in length), I don’t believe this is possible unless Thunkable were to add the ability to use wildcards or regular expressions, which would be awesome.

That said, how are you getting the HTML string (such as loading via API)? And can you post a slightly longer sample of the string, including a few more characters both before and after the width and height values? That might help with a solution, as there may be some creative ways to deal with it.

1 Like

here is the code. note i have cleaned it up. removed all the crap like tags etc.

this is the unclean version.

"<p>‘A man who left a smile wherever he went’.</p>\n<p>\nThat is how Manus Kelly was described by Fr Paddy Dunne at his funeral Mass in Glenswilly this afternoon.</p>\n<p>\nHundreds of people packed into St Columba’s church while many more gathered on the lawn outside to say a final farewell to the father-of-five.</p>\n<div id=\"attachment_66781\" class=\"wp-caption aligncenter\" style=\"width: 660px\"><img class=\"size-website-image wp-image-66781\" src=\"https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd06-660x430.jpg\" alt=\"\" width=\"660\" height=\"430\" srcset=\"https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd06-660x430.jpg 660w, https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd06-400x260.jpg 400w\" sizes=\"(max-width: 660px) 100vw, 660px\" /><div class=\"wp-caption-wrapper\"><p class=\"wp-caption-text\">Mourners in Conwal graveyard as Manus Kelly was laid to rest.</p></div></div>\n<p>\nIt is five days since Manus Kelly was killed on the Fanad Loop stage of the Donegal International Rally, an event he won three times.</p>\n<p>\nIn a fitting tribute, it was the Subaru Imprezza he won those three titles in that led his coffin to the little church high on a hill looking over Glenswilly.</p>\n<p>\nFour different guards of honour were formed as the cortege made its way from the Kelly family home to St Columba’s and on to Conwal cemetery &#8211; one by Donegal Motor Club, one by Donegal’s councillors, a third by Glenswilly GAA Club and finally by pupils and staff of Glenswilly National School.</p>\n<p>\nAmong those in attendance at the funeral was Manus&#8217;s co-driver Donal Barrett. Fianna Fáil leader Micheál Martin was also there as was Caroline Burke, Aide de Camp to An Taoiseach Leo Varadkar. Staff from three businesses Manus operated &#8211; Tailored Facility Solutions, Uptown Cafe and Haz Waste &#8211; were also on hand to pay their respects.</p>\n<p>\nAs she entered St Columba&#8217;s Manus Kelly’ wife Bernie offered a gentle smile to all those who had gathered outside for the funeral service.</p>\n<div id=\"attachment_66782\" class=\"wp-caption aligncenter\" style=\"width: 660px\"><img class=\"size-website-image wp-image-66782\" src=\"https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd03-660x430.jpg\" alt=\"\" width=\"660\" height=\"430\" srcset=\"https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd03-660x430.jpg 660w, https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd03-300x195.jpg 300w, https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd03-768x500.jpg 768w, https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd03-400x260.jpg 400w, https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd03.jpg 1280w\" sizes=\"(max-width: 660px) 100vw, 660px\" /><div class=\"wp-caption-wrapper\"><p class=\"wp-caption-text\">Fianna Fáil leader Micheál Martin and Charlie McConalogue were among those who gathered at the church.</p></div></div>\n<p>Ahead of the Mass, a number of items were brought to the altar, each of them a symbol of Manus Kelly’s life. Among them was the Jim Kennedy Memorial Trophy, presented to the winner of the Donegal Rally each year. A family photo was also presented by Manus’s son Mandy while Caolan handed over a Glenswilly GAA jersey. Manus’s racing helmet also formed part of the offerings as did a little Honda 90, a Donegal County Council tie and a glass ornament given to him as part of a civic reception held for him and co-driver Donal Barrett in 2018.</p>\n<p>\nAddressing the packed church, Fr Paddy Dunne, one of nine clergymen involved in the service, welcomed everyone, particularly the ‘rally family’ who he said had been such a big part of Manus’s life.</p>\n<div id=\"attachment_66783\" class=\"wp-caption aligncenter\" style=\"width: 660px\"><img class=\"size-website-image wp-image-66783\" src=\"https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd02-660x430.jpg\" alt=\"\" width=\"660\" height=\"430\" srcset=\"https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd02-660x430.jpg 660w, https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd02-400x260.jpg 400w\" sizes=\"(max-width: 660px) 100vw, 660px\" /><div class=\"wp-caption-wrapper\"><p class=\"wp-caption-text\">Rally cars parked in silent tribute at Manus&#8217;s parents&#8217; home.</p></div></div>\n<p>\nFr Dunne said the 41-year-old was a man loved deeply by the community in which he lived.</p>\n<p>\n“Wherever he went he took a smile with him but he never took it back with him again, instead he left it in the hearts of those he met,” said Fr Dunne.</p>\n<p>\n“He knew he was loved so deeply, in fact he could not have been loved any more deeply.”</p>\n<div id=\"attachment_66784\" class=\"wp-caption aligncenter\" style=\"width: 660px\"><img class=\"size-website-image wp-image-66784\" src=\"https://donegalnews.com/wp-content/uploads/2019/06/kellyfuneral270619dd09-660x430.jpg\" alt=\"\" width=\"660\" height=\"430\" srcset=\"https://donegalnews.com/wp-content/uploads/2019/06/kellyfuneral270619dd09-660x430.jpg 660w, https://donegalnews.com/wp-content/uploads/2019/06/kellyfuneral270619dd09-400x260.jpg 400w\" sizes=\"(max-width: 660px) 100vw, 660px\" /><div class=\"wp-caption-wrapper\"><p class=\"wp-caption-text\">Manus&#8217;s remains are carried through a rally finishing ramp in a tribute to the champion driver.</p></div></div>\n<p>\nFollowing the church service, Mr Kelly’s remains were led through a race finish arch bearing the words: Rest in peace Manus.</p>\n<p><em><strong>See the Donegal News on Monday for further coverage</strong></em></p>\n"
1 Like

So I took just one line of that, containing an image, and cleaned it up so it read:

<img src="https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd06-660x430.jpg" width="660" height="430">

and then I replaced

width="

with this

width="200" null="

and did the same for

height="

to replace it with

height="200" null="

So that the original width and height are now stored in null attributes, which are ignored by WebView component.

This changes the HTML to read

<img src="https://donegalnews.com/wp-content/uploads/2019/06/thumbnail_kellyfuneral270619dd06-660x430.jpg" width="200" null="660" height="200" null="430">

And this will work no matter what the width and height values are initially set to.

Here are the blocks:

3 Likes

oh wow. that’s actually perfect. I never would have thought of this.

thank you very much

you have been a great help to me

2 Likes