Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
requests-topic
Image permissions for guests / image size in post preview
Avatar
Dosenben
Member
Free Members
sp_UserOfflineSmall Offline
Sep 17, 2012 - 6:27 am

Dear simple:press team,

 

since i've come to rely on your excellent and quick support; i'd like to do two feature requests - basically i'm fathoming if these are technically possible.

First, would there be any way to show images in posts only to registered users? Either by removing them completely when checking the thread in a guest role or by replacing them with a standardized "please register to view" - image?

Second - do you see any possibility to downsize the preview of images in the TinyMCE-window? Our forums are pretty image-heavy; and this is one of the recurring complaints.

 

much obliged as alwayssmile and best regards,

 

Ben

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Sep 17, 2012 - 6:37 am

On the first question then there is no permission built in for this. But I will open a ticket this end so we can discuss it's merits and see if we should include it.

it could be achieved using a filter to parse the post content before display and massage it accordingly. If your php is up for that I can tell you where to construct it...

On the second question I am afraid I know of no way. It is a pain for us as well. But I will do a search to see if there is anything out there that might help. It has been a long while since I last looked into it.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Dosenben
Member
Free Members
sp_UserOfflineSmall Offline
Sep 17, 2012 - 7:47 am

Hallo Andy,

 

and thanks for the quick reply - you guys never cease to amaze me in this regard! Good news regarding the first answer; and pretty much as expected concerning the Tiny-MCE preview sizes. Judging from my complete lack of ideas how to implement this; i had hoped you might pull something out of your bottomless bag of tricks laugh. So, no problem; we'll have to live with that.

My PHP-skills are taking shape; so if it isn't too much trouble i'd very much like to see that idea content filter idea.

 

best regards and many thanks,

 

Ben

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Sep 17, 2012 - 8:18 am

Well the first thing to say is that SP filters are exactly the same as WP filters and used in the same way. So if you are unsure about them then you can read up all about them on the WP codex. They are VERY easy to use.

The filter in SP you would need is called 'sph_display_post_content_pre_filter'. This passes in the $content variable and at the end of the filter you need to return the $content massaged appropriately.

But the other thing you need is information about the current user so you will need to decide what data to use as a test on whether you need to parse the content and change it or not.

Globalise the variable $spThisUser. This will ALWAYS return a data object pertaining to the current user making the request. To see what data is available in $spThisUser go to the forum admin > Toolbox > Data Inspector and turn on the option to display it. Next time you run a forum page you will see the available data.

So you should end up with something like:

add_filter('sph_display_post_content_pre_filter', 'my_parse_function');
function my_parse_function($content) {
    global $spThisUser;
    if($spThisUser->XXXXX == YYYYY) {
        $content = ZZZZZ;
    }
    return $content;
}

where XXXXX is the data item you need to check against YYYYY and ZZZZZ is the operation you want to perrorm on the $content - probably some regex to strip images.

Some notes: This will only effect display. It will not change the content of saved data. The spFunctions.php file in the SP theme templates folder is the best place for this. As always we recommend that you create your own SP theme so that any customisation is not lost during a future update. (http://codex.simple-press.com/.....g-a-theme/)

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626