Add image dimention after product image name in bulk - database

I have an E-commerce website and have multiple products and images.
I want to add dimensions after every product images which have already uploaded.
Ex: product_name_1024x1024
Is there any way or I have to rename images 1 by 1.

I would recommended installing Netzarbeiter_NicerImageNames; https://github.com/Vinai/nicer-image-names
With this extension, you can define a mask for the image file names being shown on the frontend. Unfortuantely, it does not have a %width or %height attribute by default so you'll need to modify the extension.
I've taken a quick look and can point you in the right direction; add the filename variable as an argument to _getGeneratedNameForImageAttribute() so it will be _getGeneratedNameForImageAttribute($attributeName, $map = null, $forFiles = true, $fileName = null). Use getimagesize() to find width and height attribute when $fileName is not null and map 'width' and 'height' to these variables (see requestHost for example). Then look for every place in the code where _getGeneratedNameForImageAttribute() is called and add in the filename variable used within that function.
Finally, add the %height and %width variables to your map in the configuration under Catalog.

Related

URL Type Hierarchy in Adobe DTM

I'm trying to create a page type hierarchy where I can use it both a page hierarchy as well as props and evars, using the page URL. In a nutshell my URL would look something like this:
http://www.domain.com/BrandHomePage/SuperCategory/ProductCategory/Product
The mindset is to take the URL and use a data element to split the URL, and then capture the values into separate data elements that could also be used in a page hierarchy.
var url = "http://www.domain.com/part1/part2/part3/part4"
var parts = url.split('/').splice(2);
console.log(parts);
var baseUrl = parts[0];
var part1 = parts[1];
var part2 = parts[2];
var part3 = parts[3];
var part4 = parts[4]
My question is, would it even be possible to capture each individual portion of the URL into separate data elements? Or is my approach overkill.
Create a Data Element
The following will create a Data Element that returns an array containing up to 4 elements, depending on how many dir levels there are in the URL.
Go to Rules > Data Elements > Create New Data Element
Name it "hier1" (no quotes).
Choose Type Custom Script and click Open Editor.
Add the following code to the code box:
return location.pathname.split('/').filter(Boolean).slice(0,4);
When you are done, Save Changes.
Populate the Hierarchy Variable
Here is an example of populating hier1 on page view.
Go to Overview > Adobe Analytics Tool Config > Pageviews & Content
Under Hierarchy, select Hierarchy1 from the dropdown (this is shown by default).
To the right of the dropdown, in the first field, add %hier1%
Leave the other 3 fields blank.
Leave Delimiter as default comma , (it doesn't matter what you put here).
Note: DTM stringifies the returned array (String(Array) or Array.toString()) from the Data Element, which is effectively the same as doing Array.join(','). This is why the above shows to only put the Data Element reference in the first field, and the Delimiter is ignored.
If your implementation uses a delimiter other than a comma, see additional notes below.
Additional Notes
Populating other Variables
You can also reference %hier1% to populate other variable fields in the Global Variables section. Note that the data element will be stringified with default comma delimiter.
Alternatively, you may consider using Dynamic Variable syntax (e.g. D=h1) as the value, to shorten the request URL. If you are using the latest AppMeasurement and Marketing Cloud Service libraries, this isn't a big deal (the libs will automatically use a POST request instead of GET request if the request URL is too long).
Using the Data Element in Custom Code Boxes
You can use _satellite.getVar('hier1') to return the data element. Note that this returns an array, e.g. ['foo','bar'], so you need to use .join() to concatenate to a single delimited string value.
Using a different Delimiter
If your implementation uses a delimiter other than a comma (,) and you use the same alternate delimiter for all your variables, you can update the Data Element as such:
return location.pathname.split('/').filter(Boolean).slice(0,4).join('[d]');
Where [d] is replaced by your delimiter. Note that this will now cause the Data Element to return a single concatenated String value instead of an Array. Using %hier1% syntax in DTM fields remains the same, but you will no longer need to use .join() in Custom Code boxes.
If your implementation uses different delimiters for different variables, implement the Data Element per the original instructions in the first section. You may use %hier1% syntax in DTM fields only if the delimiter is a comma. For all other delimiters, you will need to populate the variable in a custom code box and use a .join('[d]').
Capturing more than Four Directory Levels
Since you are no longer trying to put a value in four hierarchy fields, you may consider pushing more levels to hier1 or other variables.
In the Data Element, change the 4 in .slice(0,4); to whatever max level of dirs you want to capture. Or, if you want to capture all dir levels, remove .slice(0,4) completely.

Imagemagick using metadata properties to mass rename images

I have got a ton of dicom files that I want to mass rename using their properties tags.
My question is, what is the syntax for taking a property tag(such as dcm:SeriesNumber) for every image and using it to rename the images in the directory?
I'm guessing it involves breaking it down to the relevant tag using -identify -verbose and then somehow passing that string over to the filename property?
Really would appreciate the help(using win10 command line).
Figured it out.
convert *.dcm -set filename:f "%[dcm:SeriesNumber]"_"%[dcm:AcquisitionNumber]" "%[filename:f].jpg"
the "" after filename:f hold the string that's going to represent the file name
[] brackets hold the metadata property, that you can chain by using % percentage sign which declares a new property

How to set a block for dynamic node in DRUPAL 7

I am new to Drupal. I have created a block that I want to show on some specific pages. Like if the url is "/node/2278" then I want to show the block for all the page under this "/node/2278". This may be /node/2278/1 or /node/2278/any-number.
You can use the Followings Path configurations
using (node/2278) -> the block will display only on node/2278.
using (node/2278/*) -> the block will display on node/2278/12 where * can be any text or number
using (node/2278/*/*) -> the block will display only on node/2278/12/45 where * can be any text or number
Use "/node/2278/*" , I think it actually tells you that the star can be a wildcard under the textfield where you enter it.
Don't forget you can set up url aliases so the path does not have to be "node/..." but can be whatever you want (admin/config/search/path/patterns)

In CakePHP, how do I go about making the following manipulation to my specific text files, and caching it?

Essentially at the moment I have a text file written in the script of another language. It will be stored as an element, and called to be served up as text when needed.
I want to manipulate this file with the following:
Replace all the existing variables with a php array value storing that variable name. So if the variable looks like #foo, it becomes $variables['foo'].
Create an array out of the entire file, making each line a row in the array.
The result is something like
return array(
'first line of code which has a variable called ' . $variables['foo'] . 'in it',
'second line...'
);
What would the simplest method be to go about this, and is there a way to cache the process, or should I perhaps just save and store the new file some where I can access it?
Thank you!
Use str_replace() (documentation: php.net) to replace all occurences
Use explode() in the following way: How to put string in array, split by new line?
Caching.
I suggest you use View caching, a built in CakePHP helper.
To distinguish between the different caches for the different variable names, make sure you call the controller function with a parameter that discriminates among the variable names. E.g.:
public function generate_script($varname){
// some code
}
If the discriminating variable is not known on calling the controller method (but is e.g. determined inside the controller method), you should look into the Cache API

display mat file in matlab

I want to display mat file's content to see all the results. I know that I can load it and then double click on it the content are display in the workspace, this case happen when the mat file content few information but when I have mat file content information for more than 13000 record I can't display it. could please any one help me to find any way to display mat file as table?
thanks
I do not know the format of your data (multi-dimensional, structs, cell-arrays), but there is a function called "openvar" which can be very useful for these things.
Let's define a large random 500x500x10 3d-matrix:
large = rand(500,500,10);
This variable contains 2.5 million double-values and takes up close to 20MB of memory. Opening this in the variable editor by double click in the Workspace window on "large" will usually (atleast on my system) give the following message:
"Cannot display summaries of variables with more than 524288 elements."
But you can use the "openvar"-function to open certain parts:
openvar('large(:,:,1)'); %# pass the argument as a string.
This will open the first "layer" of matrices in your Variable Editor (a 500x500 matrix in this case). This is useful if you need to look into certain parts of a large variable.
Of course you can always define new variables that contain subsets of your larger variable:
less_large = large(:,:,1);
... and then open "less_large" in the variable editor by double clicking on it in the workspace-window. But sometimes the "openvar"-method is a bit faster/easier.
You have a few options. Starting from a clear workspace, you could load the mat file into the workspace. Anything now in the workspace is in the mat file. You can use the variable viewer or parse with scripts.
If you have the Simulink toolbox, you can use Simulink.saveVars to save the contents of the workspace to a human readable m-script that would generate the same contents. It's a shame that you need Simulink to do this, as this function has nothing to do with Simulink.
How about after loading the data, and use whos to display the variables in current workspace? Note that you may want to clear all the other variables before displaying them.

Resources