Help with sharing from custom webview

Hello Koders!
Hope you’re doing fine

I’ve made an app in which I’m showing articles from my blog now i want to give an option of sharing

I’m using Custom Webview Extension to show my blog articles

When someone click on Share i want to share the article (either as a text or image but not as a url)

  1. I’ve tried ComponentToImage extension (to convert my custom webview component to image) it’s good but problem is the height and width of the vertical arrangment is not adjusted to the article size and because of this i get blurry image & even if add height and width of vertical arrangment manually still i get some articles blurred because some articles are lengthy

  2. Second thing I’ve tried is using WEB component in which i set url to my blog url after that I’ve added device utility to get text from my blog article, now if i add title> text /title> then I’ll get my article title
    But i couldn’t get the description (post) and image from the article

It would be great help if someone help regarding this

P.s. I’ve searched the community there are topics but none of them works properly

Thank you

what is your site url ?
provide the link

Try to use JS Command in Webview

Here’s the link

This is one of the 4 links that I’m going to be using

& If you’re talking about this component
Screenshot_20220302-100837

Then I’ve tried this but the results come as “null”

You want to share text right ?

Title
Image
Text

If possible!

Use this as Evaluate Javascript
It Will return the Text Paragraph
and when you got the text then use share component to share it

(function() {  
var post = new Object();
    data = document.getElementsByTagName("p");
    for(var i = 2; i < data.length; i++) {
        post[i] = data[i].innerText; }
return JSON.stringify(post);
})();

And Similarly use JS for others

Thank you

It’s working for the post now!

But i don’t know how get image?

Can you please let me know about it

Use this to get Post Title
document.getElementsByClassName("post-title entry-title")[0].innerText;

Use this to get image from the post
document.getElementsByTagName("img")[0].src;



1 Like

Thank you so much for your help everything is working fine now

Thanks alot!!!:relaxed:

One last help

I’m sorry asking for too much :pensive:

When i use join text component it only sharing title
And for the image it’s sharing the link

Do you know how can i sperate them and share together?

Show Block Image

I’m trying with different blocks but still not successful

You Are Doing Wrongway
Let Me Show Example

You’re right :sweat_smile:


(function() {
var data = new Object();
var content = new Object();
 
data.title = document.getElementsByClassName("post-title entry-title")[0].innerText;
data.image = document.getElementsByTagName("img")[0].src;
para = document.getElementsByTagName("p");
    for(var i = 2; i < para.length; i++) {
        content[i] = para[i].innerText; }
var allData = new Object();

allData = {data, content};
return JSON.stringify(allData);
})();

Try this

Output

{
  "data": {
    "title": "બનાસકાંઠામાં જળ સંકટ ઘેરું બનતાં ખેડૂત આંદોલનના એંધાણ",
    "image": "https://static.gujaratsamachar.com/content_image/content_image_619f6541-fd2e-4b5f-a0cd-217cb0d9a30c.gif"
  },
  "content": {
    "2": "પાલનપુર, તા.27",
    "3": "બનાસકાંઠા જિલ્લામાં ઘેરા બની રહેલા જળસંકટને નિવારવા જન આંદોલનના મંડાણ થયા છે. જેમાં પાલનપુર તાલુકાના કોટડા ગામે પચાસ ગામના ખેડૂતોની બેઠક મળી હતી. જેમાં જળ સંકટ મામેલ આગામી સમયમા ઉગ્ર આંદોલન કરવાની રણનીતિ ઘડવામાં આવી હતી.",
    "4": "પાલનપુર તાલુકાના મલાણા ગામ સહિત આજુબાજુ પચાસ જેટલા ગામમો ભૂગર્ભ જળ સ્તર ઉડા જઇ રહ્યા હોય સિંચાઇ અને પીવાના પાણીની વિકટ સમસ્યા સર્જાય છે.ત્યારે આ પંથકમાં પાણીની સમસ્યાના ઉકેલ માટે મલાણા ગામના તળાવમાં પાણી નાખવાની માંગમાં છેલ્લા ૩૦ વર્ષથી રાજકીય નેતાઓ લોલીપોપ આપી રહ્યા હોય  આ પંથકમાં જળ સંકટ ઘેરું બનું રહ્યું હોય જળ સંકટની સમસ્યાના કાયમી નિરાકરણ માટે રવિવારે ૫૦ ગામના આગેવાનોએ બેઠક યોજી હતી.જેમાં  આગામી તા.૭ માર્ચે ના રોજ એક સો ટ્રેક્ટરોમાં પાંચ હજાર લોકો જોડાઈ પાલનપુર શહેરમાં રેલી યોજી સરકારને જગાડવાનો પ્રયાસ કરશે અને જો સરકાર ખેડૂતોના પાણીના પ્રશ્નનો ઉકેલ લાવવામાં નહીં સાંભળે તો મલાણા પંથકના પચાસ ગામના ખેડૂતો આગામી સમયમાં યોજાનાર વિધાનસભાની ચૂંટણીનો બહિષ્કાર કરવાની રણનીતિ ઘડવામાં આવી હતી.",
    "5": "વિધાનસભા ચૂંટણીનો બહિષ્કાર કરવાની ચીમકી",
    "6": "ભારતીય કિસાન સંધના પ્રમુખ માવજીભાઈ પટેલે જણાવ્યું હતું કે, મલાણા વિસ્તારના જળ સંકટના કાયમી ઉકેલ માટે આગામી તા.૭ માર્ચે પાંચ હજાર ખેડૂતો સો ટેક્ટર સાથે પાલનપુરમાં રેલી યોજશે.તેમ છતાં તેમની માંગણી નહિ સંતોષાય તો આગામી વિધાનસભા  ચૂંટણીનો બહિષ્કાર કરવાનો ચીમકી ઉચ્ચારમાં આવી હતી.",
    "7": "\\n",
    "8": "\\n"
  }
}
3 Likes

Thanks it’s working now :heart:

I still have download the image to show but thats fine i guess

Like this

Yaa because it is in the form of url

That’ll be okay but why blogger images are not showing for download?

For example for this link

How you are trying ?
You want to download the image ?

I’ve tried using download component and it’s working fine now

But it’s not good for the users i guess because everytime they share something it’ll store the image in their folders

I’m searching community for directly sharing image with link but till now not finding anything useful

If you have any idea then I’ll appreciate it

Thank you :heart:

Nothing till now :disappointed_relieved:

Found the solution finally :grinning_face_with_smiling_eyes:

If anyone wants to share image from url without downloading then this is the method

Thank you @Decoder_360 for your help :pray:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.