mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-22 07:12:31 +01:00
feat(torrents): torrents cover image support crop
This commit is contained in:
1
config/env/default.js
vendored
1
config/env/default.js
vendored
@@ -73,6 +73,7 @@ module.exports = {
|
||||
},
|
||||
cover: {
|
||||
dest: './modules/torrents/client/uploads/cover/',
|
||||
crop: './modules/torrents/client/uploads/cover/crop/',
|
||||
temp: './modules/torrents/client/uploads/temp/',
|
||||
limits: {
|
||||
fileSize: 2 * 1024 * 1024 // Max file size in bytes (2 MB)
|
||||
|
||||
@@ -959,7 +959,7 @@
|
||||
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TORRENT_DELETE_SUCCESSFULLY')
|
||||
});
|
||||
|
||||
$state.go('torrents.movie');
|
||||
$state.go($state.previous.state.name || 'torrents.movie');
|
||||
}
|
||||
|
||||
function errorCallback(res) {
|
||||
|
||||
@@ -478,7 +478,8 @@
|
||||
|
||||
vote_average: 0,
|
||||
vote_total: 0,
|
||||
vote_count: 0
|
||||
vote_count: 0,
|
||||
cover_crop: false
|
||||
};
|
||||
|
||||
mtDebug.info($scope.uImages);
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
result = tmdbConfig.posterListBaseUrl + item.resource_detail_info.poster_path;
|
||||
break;
|
||||
default:
|
||||
result = '/modules/torrents/client/uploads/cover/' + item.resource_detail_info.cover;
|
||||
result = '/modules/torrents/client/uploads/cover/' + (item.resource_detail_info.cover_crop ? 'crop/' : '') + item.resource_detail_info.cover;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@
|
||||
result = tmdbConfig.posterImgBaseUrl + item.resource_detail_info.poster_path;
|
||||
break;
|
||||
default:
|
||||
result = '/modules/torrents/client/uploads/cover/' + item.resource_detail_info.cover;
|
||||
result = '/modules/torrents/client/uploads/cover/' + (item.resource_detail_info.cover_crop ? 'crop/' : '') + item.resource_detail_info.cover;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@
|
||||
result = tmdbConfig.posterImgBaseUrl + item.resource_detail_info.poster_path;
|
||||
break;
|
||||
default:
|
||||
result = '/modules/torrents/client/uploads/cover/' + item.resource_detail_info.cover;
|
||||
result = '/modules/torrents/client/uploads/cover/' + (item.resource_detail_info.cover_crop ? 'crop/' : '') + item.resource_detail_info.cover;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,9 +603,22 @@ exports.create = function (req, res) {
|
||||
var cv = req.body.resource_detail_info.cover;
|
||||
var oc = config.uploads.torrent.cover.temp + cv;
|
||||
var nc = config.uploads.torrent.cover.dest + cv;
|
||||
var cc = config.uploads.torrent.cover.crop + cv;
|
||||
copy(oc, nc, function (err) {
|
||||
if (err) {
|
||||
mtDebug.debugRed(err);
|
||||
} else {
|
||||
sharp(nc)
|
||||
.resize(400)
|
||||
.toFile(cc, function (err) {
|
||||
if (err) {
|
||||
mtDebug.debugError(err);
|
||||
} else {
|
||||
torrent.resource_detail_info.cover_crop = true;
|
||||
torrent.markModified('resource_detail_info');
|
||||
torrent.save();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (req.body._uImage.indexOf(cv) < 0) {
|
||||
@@ -617,7 +630,7 @@ exports.create = function (req, res) {
|
||||
req.body._uImage.forEach(function (f) {
|
||||
var oi = config.uploads.torrent.image.temp + f;
|
||||
var ni = config.uploads.torrent.image.dest + f;
|
||||
var cr = config.uploads.torrent.image.crop + f;
|
||||
var ci = config.uploads.torrent.image.crop + f;
|
||||
|
||||
move(oi, ni, function (err) {
|
||||
if (err) {
|
||||
@@ -625,7 +638,7 @@ exports.create = function (req, res) {
|
||||
} else {
|
||||
sharp(ni)
|
||||
.resize(200)
|
||||
.toFile(cr, function (err) {
|
||||
.toFile(ci, function (err) {
|
||||
if (err) {
|
||||
mtDebug.debugError(err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user