#1 WordPress forum plugin created by gVectors Team

wpForo – WordPress Forum Plugin
  • Home
  • Forum
  • Migrate to wpForo
  • Addons
  • Addons Demo
  • Documentation

Forum

Home | Forum

wpDiscuz - WordPress Comment Plugin
  • Forums
  • Members
  • Recent Posts
Forums
Main Support Forums
How-to and Troubles...
Uploading and Embed...
 
Share:
Share
Tweet
Share
Notifications
Clear all

Script [Solved] Uploading and Embedding images

Page 1 / 14 Next
    Last Post
RSS

sharonq
Posts: 1
 sharonq
Topic starter
October 17, 2016 7:23 am
(@sharonq)
New Member
Joined: 6 years ago

I really need an "image" button on the toolbar that they can click - then either upload an image or add in a URL.

While embedding a URL is simple for those who are technically savvy for many normal users its impossible to figure out. 

These are: I have a picture of a kitty on my PC that I want to share with the rest of my group people.  Please consider adding an "image" button that will give the option of uploading or embedding.  Most forums I have been on have this option.

 

netvilox and wbickle liked
Topic Tags
attach image attach file images
77 Replies
andreherberth
Posts: 1
 andreherberth
October 17, 2016 10:44 am
(@andreherberth)
New Member
Joined: 6 years ago

Hi. If paste an image link it should automatically embed already, although the image would need to be uploaded at an external website.

Alternatively, it is possible now to attache an image and submit, then edit the post again, copying the attachment link and pasting that in the post as to embed it as an image. 

This is not to say that a proper image button would be nice in any case though. 

netvilox liked
Robert
Posts: 8952
Robert - Twitter
 Robert
Admin
October 17, 2016 5:14 pm
(@robert)
Support Team
Joined: 6 years ago

The default attachments are not file type sensitive. This code can help to detect images and show those as image. You should put this code in WordPress active theme functions.php file:

add_filter('wpforo_content_after', 'wpforo_default_attachment_image_embed', 11);
function wpforo_default_attachment_image_embed( $content ){
if( preg_match_all('|<a class=\"wpforo\-default\-attachment\" href\=\"([^\"\']+)\"[^><]*>.+?<\/a>|is', $content, $data, PREG_SET_ORDER) ){
foreach($data as $array){
if(isset($array[1])){
$file = $array[1];
$e = strtolower(substr(strrchr($file, '.'), 1));
if( $e == 'jpg' || $e == 'jpeg' || $e == 'png' || $e == 'gif' ){
$filename = explode('/', $file); $filename = end($filename);
$html = '<a href="' . esc_url($file) . '" target="_blank"><img class="wpforo-default-image-attachment" src="' . esc_url($file) . '" alt="' . esc_attr($filename) . '" title="' . esc_attr($filename) . '" /></a>';
$content = str_replace($array[0], $html, $content);
}
}
}
}
return $content;
}

 

How to easily add custom code WordPress active theme functions.php file (without Breaking Your Site)

For an advanced file attachments features please check wpForo Advanced Attachments addon: https://gvectors.com/product/wpforo-advanced-attachments/

 

In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

Bonzo, aldrabugo, fawp and 7 people liked
7 Replies
GDL40
 GDL40
(@gdl40)
Joined: 5 years ago

New Member
Posts: 1
June 7, 2017 2:42 am
Reply toRobertRobert

Entering the code into the WP theme functions.php worked perfectly for me....THANKS!

writetoyogen
 writetoyogen
(@darjeeling)
Joined: 4 years ago

Trusted Member
Posts: 78
writetoyogen - Facebook
November 15, 2018 4:56 pm
Reply toRobertRobert

Seems interesting. I will try this.

Yogen

dhyanakendra
 dhyanakendra
(@dhyanakendra)
Joined: 3 years ago

Eminent Member
Posts: 38
dhyanakendra - Facebook dhyanakendra - Twitter
June 7, 2019 1:45 pm
Reply toRobertRobert

Hi

Added this snippet to the child theme using Code Snippets, however still not working. Am I missing out anything here? Can you help me in this regards?

May the practice of Kriya Yoga bless you with excellent quality and quantity of Life and Self Realization.
kriyayogajagat.com | kriyayogasandesh.com

Sofy
 Sofy
Admin
(@sofy)
Joined: 4 years ago

Support Team
Posts: 4057
Sofy - Facebook Sofy - Twitter
June 7, 2019 1:54 pm
Reply todhyanakendradhyanakendra
Robert

Hi @dhyanakendra,

We've just checked and the code works fine. Please make sure you've copied the correct code and added in the right place. Then delete all caches and check again. 

In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

dhyanakendra
 dhyanakendra
(@dhyanakendra)
Joined: 3 years ago

Eminent Member
Posts: 38
dhyanakendra - Facebook dhyanakendra - Twitter
June 13, 2019 3:04 pm
Reply toSofySofy
dhyanakendra
Robert

Hi

Please mark this as resolved as the issue has been resolved and the code snippet is working fine. Thank you again!

May the practice of Kriya Yoga bless you with excellent quality and quantity of Life and Self Realization.
kriyayogajagat.com | kriyayogasandesh.com

golabs
 golabs
(@golabs)
Joined: 1 year ago

Active Member
Posts: 10
April 1, 2021 1:51 pm
Reply toRobertRobert

@robert is it also possible to define what the max size should me after the upload?

Or can it somehow work together with the Imsanity plugin?

Robert
 Robert
Admin
(@robert)
Joined: 6 years ago

Support Team
Posts: 8952
Robert - Twitter
April 2, 2021 7:57 pm
Reply togolabsgolabs
Robert

@golabs,

You can use this CSS code to set max width to post images. Insert this CSS code in Dashboard > Forums > Settings > Styles > Custom CSS Code textarea, save it, delete all caches, go to forum front-end and press Ctrl+F5:

#wpforo #wpforo-wrap .wpforo-post .wpf-right .wpforo-post-content img {
    max-width: 60%;
}

In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

DeanoAus
Posts: 26
 DeanoAus
October 19, 2016 2:19 am
(@deanoaus)
Eminent Member
Joined: 6 years ago

What exactly does this code do? 

Does this detetch if the attachment is a photo, then displays it inside the post? If so, can this be edited to show a photo with dynamic resizing? I.e, it fits to the window on both desktop and mobile?

Robert
Posts: 8952
Robert - Twitter
 Robert
Admin
October 19, 2016 8:16 am
(@robert)
Support Team
Joined: 6 years ago

Does this detetch if the attachment is a photo, then displays it inside the post?

This will replace attached image link to image.

If so, can this be edited to show a photo with dynamic resizing? I.e, it fits to the window on both desktop and mobile?

All images in posts are responsive, this is too.

In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

Page 1 / 14 Next
  All forum topics
  Previous Topic
Next Topic  
Related Topics
  • Reply with attachment fails
    1 month ago
  • I want to add an image button to the toolbar.
    10 months ago
  • Images insertion with copy/paste
    2 years ago
  • Images in System Emails?
    2 years ago
  • Attachments to the post
    2 years ago
Topic Tags:  attach image (4), attach file (11), images (8),

Forum Search

Join Us!

Download wpForo plugin
on WordPress.org

wpForo Addons

wpforo-private-messages wpforo-advanced-attachments-128x128 wpforo-embeds-128x128 wpForo User Custom Fields addon wpForo – Blog Cross Posting addon wpForo Ads Manager wpForo – WooCommerce Memberships Integration wpForo Emoticons wpForo – Tenor GIFs Integration
View all Addons »

Recent Topics

  • Forum page

    By Charlespresh, 13 hours ago

  • How can I make notification bell appear site wide?

    By marios, 19 hours ago

  • wpForo not working correctly with Silk browser on Fire 7 Tablet

    By starman71, 1 day ago

  • Style Guests see "Add Topic" button - even if settings are right

    By DanielOfAnu, 1 day ago

  • Forums link on main page leads to 404, is not updated

    By Redglyph, 2 days ago

  • Creating the forum structure

    By Redglyph, 2 days ago

Topic Tags

  • translation49
  • css49
  • plugin conflict48
  • seo45
  • new features43
  • buddypress42
  • ultimate member40
  • avatar40
  • forum40
  • moderation38
  • login38
  • registration36
  • threaded layout35
  • cache33
  • editor32
  • menu32
  • shortcode30
  • spam29
  • phrases28
  • forum accesses28
View all tags (2157)

Recent Posts

  • RE: Solved: Someone registered 380,000 users on my site and they're all spam bots

    Solution, I uninstalled wpforo.

    By slimm1989, 41 mins ago

  • When is the Update Coming?

    How much longer, minimum, are we going to have to wait ...

    By Macky, 4 hours ago

  • RE: Forum page

    @dimalifragis ok thanks. u mean nothing wrong with my w...

    By Charlespresh, 7 hours ago

  • RE: Guests see "Add Topic" button - even if settings are right

    @danielofanu Fix your issues, if you don't your forum w...

    By dimalifragis, 9 hours ago

  • RE: How can I make notification bell appear site wide?

    @marios, Yous should use wpForo Profile and Notificat...

    By Martin, 19 hours ago

  • wpForo not working correctly with Silk browser on Fire 7 Tablet

    Just tried the Amazon Silk browser using an Amazon Fire...

    By starman71, 1 day ago

  • RE: Forums link on main page leads to 404, is not updated

    @redglyph Ok, take your time. wpForo has its own Menu...

    By dimalifragis, 1 day ago

Share:
Share
Tweet
Share
  Forum Statistics
20 Forums
9,747 Topics
49.4 K Posts
10 Online
43.1 K Members

Latest Post: Solved: Someone registered 380,000 users on my site and they're all spam bots Our newest member: MarleyGraham Recent Posts Unread Posts Tags

Forum Icons: Forum contains no unread posts Forum contains unread posts

Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed

Powered by wpForo | Copyright © 2016-2022 gVectors Team
Copyright Registration Service - Click here for more information or to register work
wpForo is Registered with the IP Rights Office
Copyright Registration Service

Ref: 4477265538
  • Home
  • Forum
  • Migrate to wpForo
  • Addons
  • Addons Demo
  • Documentation