Skip to content

Commit cbe8dfd

Browse files
authored
Merge pull request #6 from joshuatz/feat/uploaded-id-macro
Adding Cloudinary Public ID Macro Support ({uploadedId})
2 parents 6cb3f35 + f723bad commit cbe8dfd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Macros are case-insensitive; I'm using camelcase below just to make it easier to
2929

3030
Macro | Incoming Transformation | Outgoing Transformation | What it does
3131
--- | --- | --- | ---
32-
{uploaded} | No | Yes | Inserts public ID as overlay - "l_PUBLICID"
32+
{uploaded} | No | Yes | Inserts public ID as overlay into chain - "l_PUBLICID"
33+
{uploadedId} | No | Yes | Inserts public ID, *as-is*
3334
{width} | Yes | Yes | Inserts width in pixels of local file being uploaded
3435
{height} | Yes | Yes | Inserts height in pixels of local file being uploaded
3536
{filename} | Yes | Yes | Inserts the filename *including* the extension

models/uploader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void Uploader::receiveNetworkReply(QNetworkReply *reply){
211211

212212
if (config.usesOutgoingTransformationRawString){
213213
// Currently, it only makes sense to use this if the outgoing transformation string references the uploaded image.
214-
if (config.outoingTransformationRawString.contains("{uploaded}",Qt::CaseInsensitive)){
214+
if (config.outoingTransformationRawString.contains("{uploaded}",Qt::CaseInsensitive) || config.outoingTransformationRawString.contains("{uploadedId}",Qt::CaseInsensitive)) {
215215
QString uploadImageMacroVal = "";
216216
// We need to construct a NEW final image url
217217
// Basically need to compute string to represent the BASE (original raw image) + any incoming trans (raw trans string, named preset, etc)
@@ -227,6 +227,7 @@ void Uploader::receiveNetworkReply(QNetworkReply *reply){
227227
uploadImageMacroVal = "l_" + result.id;
228228
}
229229
QString finalOutgoingTransString = config.outoingTransformationRawString.replace("{uploaded}",uploadImageMacroVal,Qt::CaseSensitivity::CaseInsensitive);
230+
finalOutgoingTransString = finalOutgoingTransString.replace("{uploadedId}",result.id,Qt::CaseSensitivity::CaseInsensitive);
230231
// Final macro replacements
231232
finalOutgoingTransString = Uploader::macroReplacer(finalOutgoingTransString,this->m_localFilePath,QMap<QString,QString>());
232233
finalOutgoingTransString = Cloudinary::autoEscapeTransString(finalOutgoingTransString);

0 commit comments

Comments
 (0)