The files plugin is not only for image files but for other types of files, too. The original uploaded file is kept to be available for download (surely wanted with any non-image file type). The thumbnails for image files is to some extend a bonus to display the images already on-site. Still the original image files are supposed to be available for download, too.
If you don't want to keep the original image files some heavy re-writing of the files plugin code would become necessary to dffer between image type files and others, offer downloads of the original file not for images etc. I can't tell you every step necessary. I can only tell you that it is not as trivial as you might think. Maybe you want to even create a separate plugin to allow for uploads of images only (especially if you aim at offering image uploads exclusively). The plugin could be based on the files plugin without the hassle to differ between image file types and others. Still a lot of rewrite work would be necessary.
i have modified File plugin to only can save image file only . If user upload non-image it return error message. I have removed download button too . Full size image is really useless for my site , just eat my hosting storage.
maybe the solution is delete original file after thumbnail created
Can i use unlink() ?
You might want to try out https://elgg.org/plugins/1635100. Maybe this plugin in connection with a solr installation is a better (and safer) way to improve the search functionality than playing with custom database tables.
You say (Safer) ? can you tell me what the danger of custom database table ? So I can prevent it. I choose custom database table because I want full control of searching procces (to change , order, make my own search algorithm)
What I meant it safer in the sense of not breaking the integrity of the database and end up with a broken site due to errors in the database. With a custom database you would also need to maintain the table not only to add new rows on addition of content but also delete rows if the corresponding content is deleted or you would show search result pointing to non-existing content. Additionally, Elgg has an access control system for content and the Elgg search does take into account the access level of content objects to not provide search results the user has no access to. As the access level can be edited at any time you would also have to take into account the present access level of any content in your custom table to prevent search results showing up that are not accessible. Also, future updates of Elgg can change the database scheme so you might have to update your own custom table and custom search algorithm to take into account any database scheme change if the change is not compatible with your custom code (not that it might be necessary in any case but you might have to if you want to update your site to a new major Elgg version). Elgg 3.0 will bring such a change in the database scheme with merging some tables. Maybe this already makes it unnecessary to work with a custom search table as less joins should be necessary then.
The change you made in start.php in search_get_where_sql is nonsense. If you get a fatal error due to the change in search_hooks.php the change in start.php doesn't fix the problem for sure (it might only seem to do so as you don't get a fatal error anymore but only because the search parameters are modified in a way that you wouldn't get any results anyway or at least not the correct results).
Are you sure that it doesn't work with
$fields = array('title');
in seach_hooks.php? I just tried it myself and it works fine. If you still get an error with only this change you might want to look into the server log to find out what the problem is (maybe you left the comma after 'title' in the code?).
I have to correct myself. There's a fatal error indeed with only changing the $fields line in search_hooks.php.
Try it with also altering the following line:
$fields = array('title');
$where = search_get_where_sql('oe', $fields, $params, false);
Thanks , it works !!!!
Something like this:
$joins = array("JOIN {$db_prefix}metadata as mt on e.guid = mt.entity_guid
JOIN {$db_prefix}metastrings as msn on mt.name_id = msn.id
JOIN {$db_prefix}metastrings as msv on mt.value_id = msv.id"
);
$wheres = "msn.string = 'price'";
$order_by = "CAST(msv.string AS SIGNED) ASC";
$params['order_by'] = $order_by;
$params['joins'] = $joins;
$params['wheres'] = $wheres;
$entities = elgg_get_entities($params);
thanks , it works , thank you
To fetch and delete all wire postings it's best to write and execute a little php script that uses the Elgg API functions. Don't try to get rid of the wire postings by deleting stuff directly from the database because there would likely remain entries formerly connected with the deleted entries and in the worst case you break your database consistency.
A script to find and delete wire postings can look like
<?php
$autoload_path = __DIR__ . '/vendor/autoload.php';
$autoload_available = include_once($autoload_path);
\Elgg\Application::start();
if (elgg_is_admin_logged_in()) {
$access = elgg_set_ignore_access(true);
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
$entities = new ElggBatch('elgg_get_entities', array(
'type' => 'object',
'subtype' => 'thewire',
'limit' => false,
));
$entities->setIncrementOffset(false);
$count = 0;
foreach ($entities as $entity) {
$entity->delete();
$count++;
}
access_show_hidden_entities($access_status);
elgg_set_ignore_access($access);
}
echo "Found and deleted " . $count . " wire postings.";
Save it for example as wire_delete.php in the root folder of your Elgg installation and then call it in your browser while logged in as admin (url: your.site.url/wire_delete.php) and the wire entities will get deleted.
In case you are still on Elgg 1, replace the lines
$autoload_path = __DIR__ . '/vendor/autoload.php';
$autoload_available = include_once($autoload_path);
\Elgg\Application::start();
with
require 'engine/start.php';
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.