MyBB Hacks

Full Version: Thread Image
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12
Requirement: XThreads
Just for XThreads users who want to achieve this with XThreads.

File field type for Image Upload.
Create a new custom thread fields with this settings:
  • Title : Thread Image
  • Key : timg
  • Description: Max file size: 10 KB. Max image size: 200x200. Min Image Size: 75x75. Image allowed: GIF, JPEG, PNG.
    Modify it as our needs. Depends on some settings bellow.
  • Applicable Forums : Select forum(s) where this will be applied
  • Input Field Type : File
  • Valid File Extensions : gif|png|jpeg|jpg
  • Maximum File Size : 1280
    Modify it as our needs. This is the maximum file size for image can be uploaded. ( in bytes). Related to the Description setting.
  • Editable by / Required Field? : Select which usergroup can use this feature. If more than one usergroups allowed to use this feature, but not for all usergroups, select Custom (specify usergroup). This will bring the additional setting:
    • Editable by Usergroups : Select which usergroup can use this feature
  • Only Accept Image Files : Yes
  • Minimum Image Dimensions : 75x75
    Modify it as our needs. It is the smallest image dimension can be uploaded. Related to the Description setting.
  • Maximum Image Dimensions : 200x200
    Modify it as our needs. It is the largest image dimension can be uploaded. Related to the Description setting.
  • Image Thumbnail Generation : 75x75
    Modify it as our needs. It is the thumbnail size that will be displayed in threadlist. Related to Display Format setting bellow.
  • Display Format :

    HTML Code
    <a href="{URL}" target="_blank"><img src="{URL}/thumb75x75" alt="{FILENAME}" title="Click to view this thread image in full size - {$GLOBALS['threadfields']['timg']['dims']['w']} x {$GLOBALS['threadfields']['timg']['dims']['h']}" style="margin: 3px; float: left;" /></a>

    If we modify the Image Thumbnail Generation setting with different thumbnail size, change this part of the code above:

    Code:
    75x75


It should be enough as a basic settings. If we want to enhance it a bit, try to play with the Blank Replacement Value, Viewable by Usergroups and Unviewable Value settings.

Now, open up our forumdisplay_thread template. Find:
1.4:

HTML Code
<span>{$prefix} {$gotounread}<a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a>{$thread['multipage']}</span>


1.6:

HTML Code
<span>{$prefix} {$gotounread}{$thread['threadprefix']}<a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a>{$thread['multipage']}</span>


Add this variable at the beginning of the code above:

Code:
{$GLOBALS['threadfields']['timg']['value']}


That template edit should be enough as a basic. If we want to enhance it a bit, try to play more with the forumdisplay_thread template, and maybe (additional) forumdisplay_threadlist template, and combine it with our custom thread fields settings.

This is great, I've been using my own version of this for a long time Tongue
http://thesimsupply.com/forumdisplay.php?fid=92

It's really great for a downloads forum Smile
RateU, i love you man. I simply love zingaburga site. Smile)
giving this error, though we attach the specified file types.

Please correct the following errors before continuing:

    * Error attaching file for "Thread Image"; The type of file that you attached is not allowed. Please remove the attachment or choose a different type.
i tried it disabling "only image" option and it accepted, but showed as a link and i dont think disabling this "only image" option is good.
Well it tells you the issue.  You're not giving it what it considers to be a valid image.
What do you mean by that? Doesnt it allow the png files though it specifies pngs are allowed??
Invalid image can mean file type or file size or dimensions, so if the settings for an image upload is a png and 190 kb measuring 100*200 and you upload a 185kb png with dimensions 200*200 then it will be an invalid image because it failed the dimensions check.

Check all the attributes Smile
How can I make this image appear in the post icon zone?
In your forumdisplay_thread template, find:

Code:
{$icon}


Replace it with:

Code:
{$GLOBALS['threadfields']['timg']['value']}

Okay, it works fine, thanks for your time !
Pages: 1 2 3 4 5 6 7 8 9 10 11 12
Reference URL's